Skip to main content
Participating Frequently
April 29, 2016
Answered

Why is it that when I click Acrobat's Clear Form option is clears all the fields populated by a document level JavaScript, and if I save the form the start up document level JavaScript no longer functions?

  • April 29, 2016
  • 2 replies
  • 1216 views

Why is it that when I click Acrobat's Clear Form option is clears all the fields populated by a document level JavaScript, and if I save the form the start up document level JavaScript no longer functions?

This topic has been closed for replies.
Correct answer gkaiseril

Or a link to the form or a sample form with the same problem.

You have only defined the function to be executed but not executed it.

You need to add a line like:

AtStartup();

to your script.

As noted if you were set the "defaultValue" for the fields then clearing the fields would remove any entry present and restore the default values.

Or you could write a custom JavaScript to clear the fields and then execute your startup script.

2 replies

Karl Heinz  Kremer
Community Expert
Community Expert
April 29, 2016

The "reset a form" action that you can use as e.g. a button click handler will reset all fields to their default values. You can set the default value as part of the field properties. Resetting a form should not have any effect on document level functions. Are you getting any error message in the JavaScript console? What exactly is your document level script doing that is no longer working?

Participating Frequently
April 29, 2016

Not getting any errors in the JavaScript console. When I open the form the document level function runs ok. If I use Acrobat's built in Clear Form option it clears the document level function population of various fields on opening the form. If I then save the form the document level function no longer populates these fields. If I place the contents of document level function in a custom calculation script it runs ok and populates all the fields. 

Karl Heinz  Kremer
Community Expert
Community Expert
April 29, 2016

Once again, what exactly does your document level script do? Please post the whole script.

Inspiring
April 29, 2016

Can you post the script you're using?