1 Reply Latest reply on Nov 8, 2015 1:35 PM by try67

    Javascript Calculation help!

    TCrane1988 Level 1

      Having trouble with a custom calculation script for my mileage log.

      mileagelog1.png

      I need End MileageRow2 to = Start MileageRow3 if DateRow3 = DateRow2

      If DateRow3 does not = DateRow2 Then Start MileageRow3 needs to = (End MileageRow2 + 52) Unless this also occurs {CompanyDesrciptionRow2 = "Office Day"} Then Start MileageRow 3 needs to = (End MileageRow1 + 67)


      I am not very good with if then and if else statements so I am having a lot of trouble with this. Please Help!

        • 1. Re: Javascript Calculation help!
          try67 MVP & Adobe Community Professional

          It's a somewhat convoluted description, but I believe this code (used as the custom calculation script of "Start MileageRow3"), should work:

           

          if (this.getField("DateRow3").valueAsString==this.getField("DateRow2").valueAsString) {
              event.value = this.getField("End MileageRow2").valueAsString;
          } else {
              if (this.getField("CompanyDesrciptionRow2").valueAsString == "Office Day") {
                  event.value = Number(this.getField("End MileageRow1").valueAsString) + 67;
              } else {
                  event.value = Number(this.getField("End MileageRow2").valueAsString) + 52;
              }
          }