8 Replies Latest reply on Mar 1, 2017 2:43 PM by HenryRobinson

    Converting any number into a negitive percent

    HenryRobinson

      I have a filed that I want to let the user enter a number and have it converted into a negative percent. Some example entries and the result I would like.

      20 > -20%   

      -20 > -20%   

      .2 > -20%   

      -.2 > -20%

       

      I am currently using the following script trigger on exit and seems to be working for the most part. if the user enters -1 it give -100% but the user can still enter 1 and -.01 to get -1% . What I am hoping though is that there is a cleaner way to do this and one that might work even for the 1%. I need to do this on lots of fields. Any suggestions are welcome.

       

      # change to percent

      if [MyField ≥ 0]

           Set Field [MyField; MyField * .01]

      Else if [ MyField = -1]

           Set Field [MyField; -1]

      Else if [ MyField < - .999999999999999999999999999]

           Set Field [MyField; MyField * .01]

       

      # Change to negative

      if [MyField =-1]

           # do nothing

      Else if [ MyField > 0]

           Set Field [MyField; MyField * -1]