Custom Calculate JS Scripts

Applies To: Information Worker for SharePoint 2013/2016/2019 and Cloud


Scripts written in JavaScript are executed inside PDF during form runtime. They have access to the whole Acrobat form document (fields, controls and various PDF actions).

Acrobat Forms are stored  in PDF object format, and getting references to objects inside is done by JavaScript API.


Fields are data containers with the structure displayed in “Fields” pane in designer. Controls are UI controls (Text field, Check box etc.) as displayed in the “Hierarchy” pane.

Get reference to data field or control:


Scripts, which are executed on specific control (e.g. Button click) have “” variable set to current control.  - gets value of current control.

Manipulate fields /controls

Get field value:

Getting the value of the field data that the user has entered. Depending on the type of the field, may be a String, Date, or Number.

var fieldValue = this.getField("TextField1").value;   

Getting string value from field.

var fieldStringValue = this.getField("TextField1").valueAsString;   

Change field value:

this.getField("TextField1").value = 'Changed value';     

Show alert message:

app.alert({ cMsg: "Error! Try again!", cTitle: "Title here" });
cMsg A string containing the message to be displayed.
nIcon (optional) An icon type. Possible values are these: 0 — Error (default) 1 — Warning 2 — Question 3 — Status
nType (optional) A button group type. Possible values are these: 0 — OK (default) 1 — OK, Cancel 2 — Yes, No 3 — Yes, No, Cancel
cTitle (optional, Acrobat 6.0) The dialog box title. If not specified, the title “Adobe Acrobat” is used.

Make control visible / hidden

this.getField("Name").hidden = false; 
this.getField("Name").hidden = true; 


Scripting reference and more examples can be found in JavaScript for Acrobat API Reference.

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request


Please sign in to leave a comment.
Powered by Zendesk