These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Auto Date Field

Shari
Registered: Apr 23 2007
Posts: 2

I have a date field that populates the current date when the user pulls up the form, which is what I want. However, when the user saves the form and sends it to someone a few days later, whoever pulls up the form gets the current date, instead of the date the user saved it. (We need the date the form was initially filled out.) I am using Acrobat Professional 6.0.6

My Product Information:
Acrobat Standard 6.0.0, Windows
pddesigner
Registered: Jul 9 2006
Posts: 858
Try this function. It may fix that problem.

// variable to store whether document has been opened already or not
var bAlreadyOpened;

function docOpened()
{

if(bAlreadyOpened != "true")
{
// document has just been opened
var d = new Date();
var sDate = util.printd("mm/dd/yyyy", d);
this.getField("todaysDate").value = sDate;

// now set bAlreadyOpened to true so it doesn't
// run again
bAlreadyOpened = "true";
}
else
{
// document has already been opened
}
}

// call the docOpened() function
docOpened();

My favorite quote - "Success is the ability to go from one failure to another with no loss of enthusiasm.

pddesigner
Registered: Jul 9 2006
Posts: 858
I've provided links to two examples you can examine and modify the codes to suit your objective.

These two examples were developed with Acroat JavaScript. They have not been tested with LiveCycle Designer.
If you want to do this in LiveCycle, you need to download the Javascript Reference Guide for converting Acrobat Javascript to LiveCycle Javascript and modify the code accordingly.

About dateDialog.pdf - You could user this example to ask the user to enter the date in the dialog box that popups and the entry will be placed in the form field on the page. You could add a validation script to makes sure only a date is entered and in what format.

[url=http://wl.filegenie.com/~pdfmaker/dateDialog.pdf]http://wl.filegenie.com/~pdfmaker/dateDialog.pdf[/url]

About the date.pdf - This example could be used as a page open action or a document level script. Every time the page is opened, the current date is filled in the form field.

[url=http://wl.filegenie.com/~pdfmaker/date.pdf]http://wl.filegenie.com/~pdfmaker/date.pdf[/url]

I will gladly assist you with getting these scripts to work if this is what you'd like to do. Contact me at [url=mailto:pdfdesign [at] msn [dot] com]pdfdesign [at] msn [dot] com[/url]

My favorite quote - "Success is the ability to go from one failure to another with no loss of enthusiasm.

trefilov22
Registered: Jun 29 2007
Posts: 39
Did anyone get this to work? It updates the date each time I open the file. I placed the code in the Document Processing > Document Javascripts section. I am trying to do the exact same thing as Shari. Thanks in advance.