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

Problem with autofill date field.

Community Beginner ,
Feb 09, 2017 Feb 09, 2017

Hi,

I am trying to create an autofill date field on an Acrobat form that does not change once calculated, ie. the user opens the form and the date populates automatically, the user saves the form but on subsequent opening, the original date remains.

So far I have successfully created a Javascript in Page Properties Actions to print the date on opening the form but I cannot find a way of prevent further changes.  I have tried various scripts to do this but none worked for me.

I also tried creating a field level calculation which worked fine in so much that it populated the field with the date as required but I couldn't clear the form before saving it for use.  I found a debugging script to enable me to clear the field - great - but after saving and trying to use the form, the field remained blank.  So I'm back to square one.  I don't really mind if the field completes on opening the form or on a mouse click, as long as the date does not change if the form is reopened on another day.

if((typeof DEBUG !='undefined')&&(DEBUG==true))

{event.value="";}

else if(event.target.value=="")

{event.value=util.printd("dd/mm/yy",new Date());}

DEBUG=true;

this.calculateNow();

TOPICS
Acrobat SDK and JavaScript
461
Translate
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
LEGEND ,
Feb 09, 2017 Feb 09, 2017

I would test the date to see if it already had a value of not. If not then I would populate the date field.

You will have to make sure the date field is empty when you save the distribution version of the form. I would also use a document level script to fill-in the date field in order to improve the efficiency of the form. Using a calculation field will cause the script to be run each time any field that contributes to a calculation is updated. On a large complex form repeating unnecessary calculations will adversely affect the responsiveness of the form.

Translate
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 ,
Feb 10, 2017 Feb 10, 2017
LATEST

Hi.

Use this JavaScript as a document level script:

var f = this.getField("DATE");

    if(f.value == null || f.value == "") {f.value = util.printd("dd/mm/yyyy", new Date());}


Acrobate du PDF, InDesigner et Photoshopographe
Translate
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