4 Replies Latest reply on Apr 20, 2015 12:35 PM by gkaiseril

    SyntaxError: missing ; berfore statement

    JohnnyBQue Level 1

      I've got two "Date" fields/text boxes my goal is to enter a date in the "PO DATE" field/textbox then add 5 years to this date and have the new calculated date appear in the "REVIEW DATE" field/textbox both fields/textboxes are formated as "Dates" with the following custom format "mm,dd,yyyy"


      Also the code has been place in the "custom calculate script" field for "PO DATE" this may be the wrong location.


      I've tested the calculation part of the code using JavaScript debugger and it works...What I'm having trouble with is putting or assigning the calculated date into the "REVIEW DATE" field/textbox..

      How do I define REVIEW DATE this is what I believe I'm missing...


      The code below returns an error as such -  "SyntaxError: missing ; before statement 5: at line 6 (when in debugger) and when I run it in the form I get ("Invalid date/time: please ensure that the date/time exist. Field [ REVIEW DATE ] should match format mm/dd/yyyy "I have it formatted as such."


      var one = this.getField("PO DATE").value;

      var fiveDays = 5 * 24 * 60 * 60 * 1000;

      var finalTime = one + fiveDays;

      var theNewDate = new Date(finalTime);

      REVIEW DATE.value = util.printd(theNewDate.toString);        //also tried until.printd(theNewDate.toSting);


      thanks guys ....for any help...

        • 1. Re: SyntaxError: missing ; berfore statement
          try67 MVP & Adobe Community Professional

          If this is the calculation script of "REVIEW DATE", then the last line should be:

          event.value = util.printd("mm/dd/yyyy", theNewDate);

          • 2. Re: SyntaxError: missing ; berfore statement
            gkaiseril MVP & Adobe Community Professional

            What is ""REVIESDATE"?


            It is not a system object in Adobe Acrobat JS. I do not see it defined. Variables do not have a "value" property. Is this a field name, a comment name, or something else.


            If you are trying to populate the "REVIEWDATE" field's value, then this code would be better placed in the custom calculation script for the "REVIESDATE" field. And when placed there that field is the focused field for the calculation and the event so as noted, use the event.value for the object and property.


            You might want to verify your syntax for the "util.printd" method is correct. From my reading of the method, there are 2 required parameters, the format and the date object. I only see a date object forced to a string value.


            Adjusting for the "event.value", I get the following error in the JavaScript console:



            MissingArgError: Missing required argument.

            Util.printd:5:Field REVIEW DATE:Calculate

            ===> Parameter oDate.


            Also I would look at converting the value of the PO DATE field to the date object, adding the 5 days to the value of the date object, and setting the format for the REVIEW DATE field to "None" and using the util.printd method to format expected value.


            Something like:


            // get the value of the PO DATE field;

            var cOne = this.getField("PO DATE").value;

            // clear the result field;

            event.value = "";

            // compute only if there is a null value for the PO DATE

            if(cOne != "") {

            // convert PO DATE value to a date object;

            var one = util.scand("mm/dd/yyyy", cOne);

            // define 5 days in milliseconds;

            var fiveDays = 5 * 24 * 60 * 60 * 1000;

            // add five day to PO DATE object value;

            var finalTime = one.getTime() + fiveDays;

            // create new date object of PO DATE plus 5 days;

            var theNewDate = new Date(finalTime);

            // set field value to formatted value of PO DATE plus 5 days;

            event.value = util.printd("mm/dd/yyyy", theNewDate);

            // some tracing information from the script;



            console.println("PO Date value: " + cOne);

            console.println("PO Date object value: " + one.getTime() );

            console.println("PO Date object stirng: " + one.toString() );

            console.println("theNewDate value: " + theNewDate.getTime() );

            console.println("theNewDate string: " + theNewDate.toString() );

            console.println("theNewDate formatted: " + util.printd("mm/dd/yyyy" , theNewDate) );


            • 3. Re: SyntaxError: missing ; berfore statement
              JohnnyBQue Level 1

              Again GKaiseril,


              You either have no life or your a 7 year old that's been weened on java since birth...either is find by me, because you knocked out the part again...I enjoy you informative explanation(s) even when some leave me looking like a deer in headlights with drooling dripping from the corners of my mouth...


              thanks again

              • 4. Re: SyntaxError: missing ; berfore statement
                gkaiseril MVP & Adobe Community Professional

                The only difference between this an your other question is


                1. Getting the value of a field

                2. Formatting the result for the field.

                All the rest is the same. You need to convert a date string to a date object, add 5 days to that object, and format the revised object. So there is a large block of code within the middle that can remain the same. Of course this means you may not want to keep changing your variable names.