13 Replies Latest reply on Jan 14, 2018 8:30 AM by stepheng54012748

    If then question

    stepheng54012748 Level 1

      If anyone can help with a scenario that I'm struggling with I would be eternally grateful.  I am learning how to write in Javascript but am very new to this.  I'll do my best to describe what is happening and how I'm trying to write the script.  Below is the breakdown:


      Line "J10" is a sum of 5 lines.

      Line "J13" is the sum of line "J10" and "J12" ONLY if Line "J10" is greater than 0.  If Line "J10" is a negative number then Line "J13" should return 0.  I've written the script so many different ways I think I've thoroughly confused myself.  At one point, I thought I solved it.  When I enter the number and it gave the result I was looking for on the positive side and then changed the number to a negative but the result from the previous script didn't change but stayed the same.  I want to be able to write the Javascript so if I test it with a positive result it gives the result I'm looking for and if I change the test number to a negative number that it switches to a 0. It's almost as if the script is unstable.  Any input on how to write this would be so greatly appreciated.  Thank you in advance.


      Here is the latest that doesn't work.


      var theField = this.getField("V1");

      var theValue = theField.value;

      var theField2 = this.getField("V2");

      var theValue2 = theField.value2;


      if (theValue > 0) {

          this.getField("J13").value= theValue2;


      else {

           this.getField("J13").value= 0";