Skip to main content
carsteng69004442
Participant
November 11, 2020
Answered

automatisches Datum beim Öffnen.

  • November 11, 2020
  • 2 replies
  • 1692 views
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

 

This topic has been closed for replies.
Correct answer try67

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.

2 replies

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
November 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.

carsteng69004442
Participant
November 11, 2020

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.

Bernd Alheit
Community Expert
Community Expert
November 11, 2020

Where does you use the script?

carsteng69004442
Participant
November 11, 2020

Hallo Bernd.

 

unter Eigenschaften / Berechnung / Benutzerdef. Berechnungsskript

Bernd Alheit
Community Expert
Community Expert
November 11, 2020

Set the value of the field at document open.