• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

Views

1.2K

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

Community Expert , 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.

Votes

Translate

Translate
Community Expert ,
Nov 11, 2020 Nov 11, 2020

Copy link to clipboard

Copied

Where does you use the script?

Votes

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

Votes

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
Community Expert ,
Nov 11, 2020 Nov 11, 2020

Copy link to clipboard

Copied

Set the value of the field at document open.

Votes

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
Community Expert ,
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.

Votes

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.

Votes

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