6 Replies Latest reply on May 30, 2009 10:15 PM by BEARADMIN

    FORM FIELD AUTO DATE

    BEARADMIN

      HI GUYS,

       

      BRAND NEW TO THIS. I HAVE A FORM IN WHICH I WOULD LIKE TO ADD A FIELD THAT AUTOMATICALLY IS CALCULATED WITH CURRENT DATE. I DON' T WANT THIS FIELD TO UPDATE IF THE FORM IS OPENED AGAIN. ALSO, I TRIED ONE OF THE SCRIPS I SAW ON HERE, BUT IT WOULD NOT CALCULATE THE CORRECT DATE. PLEASE HELP.

        • 1. Re: FORM FIELD AUTO DATE
          Bernd Alheit Adobe Community Professional & MVP

          What is your definition of current or correct date?

          • 2. Re: FORM FIELD AUTO DATE
            gkaiseril MVP & Adobe Community Professional

            There is no need to yell!!!

             

            The first problem that you will have is how to save a form without the date and how to have the date calculated.

             

            In Acrobat. you can test a field value to see if it is blank and then set the value for the field. Next you need to keep the value if the form is cleared or reset, you can use the 'defaultValue' field property for this. The following script will work, but you need to clear the default value of the form field before saving the form for distribution.

             

            // document level function

            function SetDate(sFormat, sField) {
            // update date field's default value is empty
            if(this.getField(sField).defaultValue == '') {
            var oMyDate = new Date();
            this.getField(sField).value = util.printd(sFormat, oMyDate); // set display
            // set default value so value restored on clear

            this.getField(sField).defaultValue = util.printd(sFormat, oMyDate);
            // some testing code
            app.alert('Date updated');
            } else {
            // some testing code

            app.alert('Date not updated');
            }
            return true
            } // end SetDate function

             

            // now call function

            SetDate('mmm d, yyyy', 'MyDateFieldName');

             

            // end document level function

             

             

            The above code assumes your system has the correct date and time and local time zone set, as Acrobat uses your system time settings including the time zone offset.

            • 3. Re: FORM FIELD AUTO DATE
              HotDangBobby

              This is simple.

               

              Let me know if this is what you needed

               

              var bFirstTime=1;
              var f=this.getField("todaysDate");

               

              if (bFirstTime=1) {
              f.value=util.printd("mm/dd/yyyy",new Date());
              bFirstTime=0;
              //app.bFirstTime);
              }

              • 4. Re: FORM FIELD AUTO DATE
                BEARADMIN Level 1

                Well I want the form to automatically insert date. It was doing so, but the date was incorrect; I was creating It on 5/28/09 and it was inserting 01/02/00...? and then, since these are file reports, I want the form to not update date whenever the form is opened.

                 

                Thank  you for looking into my question.

                 

                -Diana

                • 5. Re: FORM FIELD AUTO DATE
                  BEARADMIN Level 1

                  I will try..

                   

                  Thank you, will update you.

                   

                  -Diana

                  • 6. Re: FORM FIELD AUTO DATE
                    BEARADMIN Level 1

                    I will try..

                     

                    Thank you, will update you.