1 Reply Latest reply on Sep 26, 2014 10:00 AM by George_Johnson

    Override Simple Calculation


      Hello everyone, I have no idea about javascript but would like to know if someone can help me with this simple calculation. What I want is for the field to calculate the amount due for an item which has a price of $ 108, but if the rep wants to override the total amount to leave the overwritten amount on.


      On the field I am doing the calculation (RESULT) I would like it to calculate the quantity on the EEQTY field * 108, and then let the user override the amount if they feel like it, so it would go like this:


      RESULT = EEQTY * 180 or whatever the guy puts on the RESULT field


      I will then be adding all the RESULT fields in order to make up the total.


      Thanks in advance!

        • 1. Re: Override Simple Calculation
          George_Johnson MVP & Adobe Community Professional

          You can use a script like the following so that the RESULT field only calculates if the EEQTY field is changed:



          // Custom calculation script for RESULT field

          (function () {


              // Get a reference to the quantity field

              var f = getField("EEQTY");


              // Only calculate if a change in the quantity triggered this script

              if (event.source && event.source === f) {

                  event.value = util.printf("%.2f", +f.value * 108);  // Round to nearest cent