2 Replies Latest reply on Jun 27, 2016 9:26 PM by Duquette

    Is there a way to only assign a variable if the field is populated?

    Duquette

      I have a form that calculates several variables based on input. It is driving me nuts. It will work great for a few months then it will stop working correctly and the debugger will come up with a lot of errors. The form tracts quantities for several different vessels and needs a lot of variable - I do not know if this has anything to do with it.

       

      I am getting the error:

       

      TypeError: this.getField(...).value.toUpperCase is not a function

      34:AcroForm:DPoundsA:CalculateException in line 34 of function top_level, script AcroForm:DPoundsA:Calculate

       

       

      Here is a sample of the coding for one of the 13 lines to calculate the quantity left in the vessels, is there anyway to simplify this:

       

      //Uses the input from the Trailer Drop Weight field to determine how much to subtract from the Drop Weight input to calculate Heel Pounds

       

      var heel = this.getField("DWieght").value;

       

      if (heel>0) {

          if (this.getField("Trailer").value == '86001') {
               event.value = heel-22040;
      }
          if (this.getField("Trailer").value == '86002') {
               event.value = heel-22700;
      }
          if (this.getField("Trailer").value == '4742') {
               event.value = heel-22480;
      }
          if (this.getField("Trailer").value == '86003') {
               event.value = heel-22480;
      }
          if (this.getField("Trailer").value == '86004') {
               event.value = heel-22300;
      }
          if (this.getField("Trailer").value == '86005') {
               event.value = heel-22580;
      }
          if (this.getField("Trailer").value == '86006') {
               event.value = heel-22320;
      }
          if (this.getField("Trailer").value == '86007') {
               event.value = heel-21980;
      }
          if (this.getField("Trailer").value == '86008') {
               event.value = heel-23180;
      }
          if (this.getField("Trailer").value.toUpperCase() == 'T602') {
               event.value = heel-14060;
      }
          if (this.getField("Trailer").value.toUpperCase() == 'T-602') {
               event.value = heel-14060;
      }
          if (this.getField("Trailer").value.toUpperCase() == 'T603') {
               event.value = heel-16420;
      }
          if (this.getField("Trailer").value.toUpperCase() == 'T-603') {
               event.value = heel-16420;
      }
          if (this.getField("Trailer").value.toUpperCase() == 'T610') {
               event.value = heel-21900;
      }
          if (this.getField("Trailer").value.toUpperCase() == 'T-610') {
               event.value = heel-21900;
      }
          if (this.getField("Trailer").value.toUpperCase() == 'T611') {
               event.value = heel-20940;
      }
          if (this.getField("Trailer").value.toUpperCase() == 'T-611') {
               event.value = heel-20940;
      }
          if (this.getField("Trailer").value.toUpperCase() == 'T621') {
               event.value = heel-17180;
      }
          if (this.getField("Trailer").value.toUpperCase() == 'T-621'){
               event.value = heel-17180;
      }
           if (this.getField("Trailer").value.toUpperCase() == 'T702'){
                    event.value = heel-19900;
      }
           if (this.getField("Trailer").value.toUpperCase() == 'T-702'){
                    event.value = heel-19900;
      }
           if (this.getField("Trailer").value.toUpperCase() == '2R339') {
                    event.value = heel-11280;
      }
           if (this.getField("Trailer").value.toUpperCase() == '2R338') {
                    event.value = heel-11200;
      }
           if (this.getField("Trailer").value.toUpperCase() == '2R357') {
                    event.value = heel-11200;
      }
           if (this.getField("Trailer").value.toUpperCase() == '2R358') {
                    event.value = heel-11200;
      }
           if (this.getField("Trailer").value.toUpperCase() == '1R793') {
                    event.value = heel-13360;
      }
           if (this.getField("Trailer").value == '8058') {
                    event.value = heel-22480;
      }
           if (this.getField("Trailer").value.toUpperCase() == '1R504'){
                    event.value = heel-13200;
      }
           if (this.getField("Trailer").value.toUpperCase() == '1R553') {
                    event.value = heel-13300;
      }
           if (this.getField("Trailer").value == '4180') {
                    event.value = heel-13090;
      }
      else if (this.getField("Trailer").value.toUpperCase() == 'GATX060903')
      {
           event.value = heelc-75900;
      }
      else if (this.getField("Trailer").value.toUpperCase() == 'UTLX902219')
      {
           event.value = heelc-83100;
      }
      else if (this.getField("Trailer").value.toUpperCase() == 'UTLX902227')
      {
           event.value = heelc-83200;
      }}

      else
      event.value="";