6 Replies Latest reply on May 20, 2014 5:34 PM by DuckOfDeath

    Simplified Field Notation for If/Then


      I was wondering if there is a simplified field notation for the following:


      If Field "A" equals "650", then Field "B" is populated "7.50"


      I am new to this and unfortunately, I'm trying to resolve it as simple as possible.

        • 1. Re: Simplified Field Notation for If/Then
          try67 MVP & Adobe Community Professional

          You can't enter conditional statements in the simplified field notation.

          However, you can do it with a script.

          So if this is field B's custom calculation script, enter this:


          if (this.getField("A").value=="650") event.value = "7.50";

          • 2. Re: Simplified Field Notation for If/Then

            I'm new to scripting.  This example helped me get what I wanted but if the box is checked and then unchecked, the event value doesn't go back to default.  Is there a way to do that?  Here is the calculation script I have so far:

            if(this.getField("Observedtotal2").value=="1")event.value="20";if(this.getField("Observedt otal3").value=="1")event.value="30";

            • 3. Re: Simplified Field Notation for If/Then
              gkaiseril MVP & Adobe Community Professional

              Have you opened the JavaScript console to see if there are any errors?


              Are you sure your field names are correct?


              function GetField(cName) {
              // get the field object for field cName;
              var oField = this.getField(cName);
              if(oField == null) app.alert("Error accessing field named " + cName);
              return oField;

              var Total12 = GetField("Observedtotal2");
              var Total13 = GetField("Observedt otal3");

              if(Total12.value == "1")event.value="20";
              if(Total13.value == "1")event.value="30";
              if(Total12.value == "1" && Total13.vlaue == "1") app.alert("Check the results for observations");

              • 4. Re: Simplified Field Notation for If/Then
                DuckOfDeath Level 1

                Made an adjustment:

                if(this.getField("Observedtotal1").value=="1")event.value="10";if(this.getField("Observedt otal2").value=="1")event.value="20";if(this.getField("Observedtotal3").value=="1")event.va lue="30";


                Field names are correct.  I don't know how to check for errors in console.

                The calculation works but I think I've found my issue.  What I prefer to use instead of a field value of "1", It really needs to be >"0".  The greater than symbol won't work though.  Is there a way to use >0 in Custom Calculation field?

                • 5. Re: Simplified Field Notation for If/Then
                  gkaiseril MVP & Adobe Community Professional

                  A combination of the <Ctrl> + J keys will open the JavaScript console.


                  The field names have changed form your original post.


                  if(this.getField("Observedt otal3").value=="1")event.value="30";


                  Note the space in the field name.


                  If you are comparing numbers there is no need for the quotation marks.


                  Are you sure there is not an error elsewhere in your form that is causing JavaScript to abort.


                  JavaScript processing for an Acrobat form ends when any error in a PDF document occurs.

                  • 6. Re: Simplified Field Notation for If/Then
                    DuckOfDeath Level 1

                    No Java errors.  Thanks for that tip on the java console. That space in the field name was from a cut and paste of a previous version of my script. The script works as intended, however, my situation is a little different than the original poster.  This is a behavior observation form.  There are ten time intervals with check mark boxes for each of three observations.  I'm trying to auto calculate the total possible observed that will increase with each observation performed (10, 20, 30).  My problem with using a value of 1, is that if the educator mistakenly checks a box outside the current observation, the total possible field remains at the new value ie 20, even after they uncheck it.  The only exception to that is if they had only checked one box in the current observation.  So, Instead of a value of 1 triggering the event value, it needs to be >0.  Is that possible?