0 Replies Latest reply on Dec 30, 2016 9:31 AM by justina68244594

    How do I write a Custom Calculation (JavaScript) for a field that still needs to accept manual entry?

    justina68244594 Level 1

      This is the code that I have in my text field now:

       

      var nSubTotal2 = this.getField("RTO_PAYMENT METHOD").value;

       

      var nSubTotal = this.getField("WIDTH").value;

      if( nSubTotal > 749) event.value = nSubTotal * 1;

      else if( nSubTotal < 749) event.value = " ";

       

      // Initial discount value var nSubTotal = this.getField("subtotal").value;

      if ( (nSubTotal > 749) && (nSubTotal2 < 1) ) event.value = nSubTotal * 0.50;

       

      if(!event.willCommit)    

          event.rc = !isNaN(event.change) || event.change == ".";

       

      For the most part it works, but when I try to enter a value manually it does not show the number and when the Initial Discount Value event is met, it keeps that value instead of taking the manually entered number. It was quite the process to get it to calculate what i needed and perhaps there is an easier way. The [Down Payment] field needs to draw from the WIDTH because certain sizes require different amounts (ie. 8' requires $100 down, etc.), but at the same time if the user chooses to pay by ACH [PaymentMethod] the down payment drops to $0 for sizes [8, 10, 12] and half for sizes [14, 16]. I need all that to operate off each other but also when the user manually enters a down payment of their own that needs to override the other if the minimum amount required is met.

       

      Does this make sense? My document is available for reference.