Copy link to clipboard
Copied
Hello, I have designed a form in InDesign and exported it as PDF.
I have created a text field in which the current date should be automatically inserted into this text field the first time it is opened and should not be changed again (not even the next time it is opened).
The code:
if(event.value == "")
{
event.value = util.printd("dd.mm.yyyy", new Date())
}
Now I am the author and I have to write the code in Acrobat.
However, it already sets the date, which should only happen when the actual user opens and saves the code for the first time?
How can you solve this?
Thanks
Move the code to a doc-level script (not inside a function!) and adjust it like this:
var f = this.getField("FieldName");
if(f.value == "")
{
f.value = util.printd("dd.mm.yyyy", new Date())
}
Then reset the form, save it and close it. Send that file to your users and when they open it, the field will become populated.
Copy link to clipboard
Copied
Where does you use the script?
Copy link to clipboard
Copied
Hallo Bernd.
unter Eigenschaften / Berechnung / Benutzerdef. Berechnungsskript
Copy link to clipboard
Copied
Set the value of the field at document open.
Copy link to clipboard
Copied
Move the code to a doc-level script (not inside a function!) and adjust it like this:
var f = this.getField("FieldName");
if(f.value == "")
{
f.value = util.printd("dd.mm.yyyy", new Date())
}
Then reset the form, save it and close it. Send that file to your users and when they open it, the field will become populated.
Copy link to clipboard
Copied
Thanks. thats it.
And the deactivation of javaScript in Preferences, while working on it.
Sorry, i didn't know that.
Thanks to all for the quick support.