9 Replies Latest reply on Sep 7, 2017 1:28 PM by try67

    compare text fields


      I'm sorry for not taking a more research based approach but this is a side project for my job that I can't put too much time into - I apologize if some of these questions are just very silly.


      My form is meant to use if/then calculations to return information based on data from 240ish fields that may or may not end up with data in them. The fields will be populated with information pulled from another program and are broken into three types of field "__.AC1/2/3" "__.EX1/2/3" AND "__.FN1/2/3" the idea being that AC1/EX1/FN1 will end up being populated with the information specific to one object.


      The code I'm currently working on is below:


      var a = this.getField("FLB.EX1").value

      var b = this.getField("FLB.EX2").value

      var c = this.getField("FLB.EX3").value

      var nr = event.value

      var n1 = getField("FLB.FN1").valueAsString

      var n2 = getField("FLB.FN2").valueAsString

      var n3 = getField("FLB.FN3").valueAsString

      var em1 = getField("EM.EX1").value

      var em2 = getField("EM.EX2").value

      var em3 = getField("EM.EX3").value



      if(em1 >= .3 || em2 >= .3 || em3 >= .3)

      {if(a > b && a > c)

          {nr = n1} else

      if(b > c)

          {nr = n2} else {nr = n3}}


      My questions at this point:


      1) if I declare var a = x within the custom calc for a field is that going to define "a" for all calculations in all text fields, or is it specific to that field?

      2) sometimes it seems like custom calc won't work if I have a long string of conditions {if x {if y {if z {do this} else if this {}}else this}else this} - is there a limit to that sort've formula?

      3) the above SEEMS like a super simple version of some other code that IS working within my document... but it isn't populating FLB.FN2 in the result field, and I can't for the life of me figure out why.


      Any input on the above would be deeply appreciated.




      I changed the code to read:


      if(this.getField("EM.EX1").value >= .3 || this.getField("EM.EX2").value >= .3 || this.getField("EM.EX3").value >= .3)

      {if(this.getField("FLB.EX1").value > this.getField("FLB.EX2").value && this.getField("FLB.EX1").value > this.getField("FLB.EX3").value) {event.value = getField("FLB.FN1").valueAsString} else

      if(this.getField("FLB.EX2").value > this.getField("FLB.EX3").value) {event.value = getField("FLB.FN2").value} else

      {event.value = getField("FLB.FN3").valueAsString}}


      that's working and the above was not. No idea why? Am I declaring or referencing variables incorrectly or is there some other syntax error?