automatisches Datum beim Öffnen.

New Here ,
Nov 11, 2020 Nov 11, 2020

Copy link to clipboard

Copied

Hallo, ich habe ein Formular in InDesign gestaltet und als PDF exportiert.
Ich habe ein Textfeld erstellt, darin soll automatisch beim ersten Öffnen das aktuelle Datum in dieses Textfeld eingefügt werden und nicht wieder verändert werden (auch nicht beim nächsten Öffnen).
 
Der Code:
if(event.value == "")
{
event.value = util.printd("dd.mm.yyyy", new Date())
}
 
Nun bin ich der Autor und ich muss den Code im Acrobat erst mal reinschreiben.
Allerdings setzt er mir jetzt schon das Datum, welches erst beim ersten Öffnen und Speichern des eigentlichen späteren Users passieren soll?
 
Wie kann man dies lösen?
Danke
 
-----
 

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

 

TOPICS
Acrobat SDK and JavaScript, Create PDFs

Views

209

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct Answer

Most Valuable Participant , Nov 11, 2020 Nov 11, 2020
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.

Likes

Translate

Translate
Adobe Community Professional ,
Nov 11, 2020 Nov 11, 2020

Copy link to clipboard

Copied

Where does you use the script?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 11, 2020 Nov 11, 2020

Copy link to clipboard

Copied

Hallo Bernd.

 

unter Eigenschaften / Berechnung / Benutzerdef. Berechnungsskript

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Nov 11, 2020 Nov 11, 2020

Copy link to clipboard

Copied

Set the value of the field at document open.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Most Valuable Participant ,
Nov 11, 2020 Nov 11, 2020

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 11, 2020 Nov 11, 2020

Copy link to clipboard

Copied

LATEST

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines