5 Replies Latest reply on Mar 13, 2015 11:57 AM by try67

    Script help

    karenwspack

      I am trying to create a Java Script calculation to give me a sentence where the date will change (to the current date)anytime the file is opened.

       

      I can get the date but i can't get the copy to appear on either side of the date.

      this script gives me the date

      event.value = (new Date()).toString(); AFDate_FormatEx("mmm dd, yyyy");

       

      but whats the secret to getting copy added to either side?

      I want it to say "printed <date>. Printed copies of this document are considered UNCONTROLLED."

       

      i'm new to this and I'm not sure what to look for anymore. Thanks in advance for any help.

       

      Karen

        • 1. Re: Script help
          karenwspack Level 1

          well, I figured it out...I needed a second field.

           

          // Get first field value

           

          var v1 = getField("printed date").value;

           

           

           

          event.value= "Printed on " + v1 + ". Printed copies of this document are considered UNCONTROLLED.";

          • 2. Re: Script help
            try67 MVP & Adobe Community Professional

            Actually you don't need two fields, just a different code:

             

            event.value = "Printed on " + util.printd("mmm dd, yyyy", new Date()) + ". Printed copies of this document are considered UNCONTROLLED.";

            • 3. Re: Script help
              karenwspack Level 1

              thanks - that's even better! Much appreciated

              • 4. Re: Script help
                karenwspack Level 1

                The person I did this script for says the date is not changing with each print. It still has the old date. do you have any other suggestions?


                event.value = "Printed on " + util.printd("mmm dd, yyyy", new Date()) + ". Printed copies of this document are considered UNCONTROLLED.";


                I also tried:

                var f = this.getfield("DatePrinted");

                f.hidden = false;

                f.value = "Printed on " + util.printd("mmmm dd, yyyy", new Date()); + " Printed copies of this document are considered UNCONTROLLED.";

                • 5. Re: Script help
                  try67 MVP & Adobe Community Professional

                  If you want the text to update each time the file is printed then you need to place the script as the WillPrint event of the document. You'll also need to adjust it a bit.