7 Replies Latest reply on Jun 18, 2013 2:15 PM by gkaiseril

    subtract and divide in a single custom calc script

    glvmlss01 Level 1

      I am very new to all this and have created one custom script with help from this community.  I am trying to get the precentage of increase when a person gets a pay increase..


      My fields are Pay1=old rate, Pay2= new rate, Pay3=increase amount and Pay4 precentage of increase.


      I have the following script in the Pay4 fields:


      var P1 = Number(this.getField("Pay1").value);

      var P2 = Number(this.getField("Pay2").value);

        if (P1 === 0) {P1 =1}

        if (P2 === 0) {P2 =1}

      var P3R = P1/P2*100;

      var PERC3NT = 100 - P3R;

      PERC3NT = PERC3NT / 100;

      this.getField("Pay4").value = PERC3NT;


      I noticed if I replace "Pay2" with "Pay3" i get a smaller amount as the precentage.  I know that in order to get the precentage i need to divide the difference of  the increase by the old rate and times by 100.  I seem to be missing something becasue even when I change the rate to one dollar more my precentage doesn't seem right.  Can you help.