2 Replies Latest reply on Mar 9, 2016 9:00 AM by d787685

    If blank then do not calculate?

    d787685

      I'm attempting to create a custom calculation script for a discount field (in $) where it takes the value of a master discount field (in %) times the quantity of the item by the price. The issue is that I have the master discount field set to be blank should no value be entered and this seems to interrupt the calculation. I'm quite inexperienced with javascript so I'd appreciate it if you could take a look at my issue and let me know what I might need to do in order to fix it.

       

      This is the simple formula that I need to get the required total:

      (QTY1*UnitPrice1)*(Discount1/100)
      

       

      I am attempting to say that if the value = blank/null then do not perform the calculation otherwise perform (A*B)*(C/100):

      if (this.getField("Discount1").valueAsString=="") then ???
      else event.value = ( this.getField("QT1").value * this.getField("UnitPrice1").value ) * ( this.getField("Discount1").value / 100 );
      

       

       

      Thank you!