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

Javascript Date

rajdeepsokhi
Registered: May 7 2007
Posts: 16

Hi,
I have a text field which shows the current date based on the following javascript-

event.value = util.printd("mmmm d, yyyy", new Date());

I want to be able to do the following-

1. The date should auto-refresh when opened in Adobe Reader. Right now I have to delete the date and tab out for it to show the current date. Otherwise it keeps showing the previous date.

2. I want to make the field editable so that the user can enter his own date if needed.

3. I want to add the weekday to the date- (Thursday, June 15, 2007)

4. I want to make the form compatible for MAC.

Thanks
Raj

gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
Your code in the "Custom Calculation script" runs only when a field has been modified, so it will not run upon initialization. You want a script the that will run on the document opening. This is usually coded as a document level script. One could make this script run if the field's default value is empty or if a document level variable indicating initialization is false.

From the Acrobat JS Reference, the util.prind description describes using the "dddd" string in the cFormat option for the long day to the date string.

George Kaiser

radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
You can use the identity parameter, to get, who is currently logged on on the machine.

Example:
console.println("Your name is " + identity.loginName);

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
Because of Adobe's security restrictions for PDF I don't think there is a solution without a folder level script for this request.

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

1josha
Registered: Apr 24 2007
Posts: 18
Radzmar,

You refer to a folder level script. What do you mean by this?

If i had a group of users accessing a pdf from a shared network drive, could your 'folder level script' provide a solution?

J
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
Folder level scripts reside in one of the Acrobat/Reader application installation folders, This can be the "JavaScripts" in the program location file or in the user application folders. You will need to know the OS being used, the version of Acrobat/Reader. More information is contained in the Acrobat JS API Reference.

Thom Parker has written:

[url=http://www.acrobatusers.com/tutorials/2006/folder_level_scripts]Entering Folder Level Scripts[/url]
[url=http://www.acrobatusers.com/tutorials/2008/10/using_trusted_functions]Using Trusted Functions[/url]

I have previously posted [url=http://www.acrobatusers.com/forums/aucbb/viewtopic.php?id=18384]How to Capture UserID and Add to Form[/url] that has sample scripts.

The above solution might also require that your users complete the identity object items in their application's preferences.

Adobe has restricted access to the 'identity' object because Acrobat/Reader and be opened within a web browser accessing a PDF on an server that is under the control of who knows and that could disclose one's userID and email. The userID is one piece of data for breaking into a system and disclosing the email address is an open invitation to spam. Your system admin would not like the userid's being disclosed and you might not like getting your email in box filled with spam.

George Kaiser