Global Scripting Variables with Adobe Forms

There may be occasions where you want to control the logic flow of an Adobe form without changing the form interface or context. Or, you may need to debug the form. Global scripting variables can be used to accomplish both.

Global scripting variables will be included in the Hierarchy, but cannot be used for default binding. Once created, their values are known to all events on the Adobe form.

As an example, from the standard object library palette, I dragged and dropped the Reset Button icon to my Interactive Adobe form and labeled it ‘Reset Changes on Form’. By design, pressing this button initializes all fields on the form. I created a global scripting variable with an initial value and changed the value within the ‘Reset Changes on Form’ click event because I wanted to know if this event was triggered.

Here are the steps to control Adobe form logic via a global scripting variable:

Issue transaction SFP and open the Adobe form in Change Mode.

Go to the Layout tab of the Form in Design View.

In the Scripting area select: Show Events with Scripts, Language FormCalc, Run At Client.

6-17-2014 1-29-10 PM.png

Go to Edit, Form Properties, Variables tab.

In the variables window click the plus sign to create variable ‘bard’ with the value 129.

6-17-2014 1-42-12 PM.png

On the form, click the ‘Reset Changes on Form’ button to show the scripting area for this event.

6-17-2014 1-50-48 PM.png6-17-2014 1-45-26 PM.png

Enter this FormCalc logic in the scripting area for the ‘Reset Changes on Form’ event.

bard = 0

xfa.host.messageBox( Concat ( “In the ResetButton click event Value of bard is “,bard),”Value data.subform1.bard” )

Click on a different field on the Form that also contains an Event with Scripts.

I chose the CARRID event where users can change Airline Carriers via a drop down box.

6-17-2014 1-58-06 PM.png

Here is the scripting for the CARRID event.

6-17-2014 1-59-50 PM.png

Enter this FormCalc logic in the scripting area for the CARRID event.

xfa.host.messageBox( Concat ( ““In the Carrid Event Value of bard is 129 “,bard),”Value data.subform1.bard” )
// if bard = 0 we know the Reset Changes on Form event was triggered and if so, we will default the
// Airline Carrier to ‘AA’ and the Carrier Name to ‘American Airlines’. 
if ( bard == 0 ) then
   data.subform1.CARRID = “AA”
   data.subform1.CARRNAME = “American Airlines”
endif

Press the Check Script Syntax button. 6-17-2014 2-03-25 PM.png Correct any syntactical errors that may exist.

Save and Activate the form.

Test the logic by clicking on the Preview PDF tab.

A JavaScript window should display “In the Carrid Event Value of bard is 129″.  Click OK.

6-17-2014 2-05-08 PM.png

Click the ‘Reset Changes on Form’ button which will trigger the event and set bard = 0.

A JavaScript window should display “In the ResetButton click event Value of bard is 0”.

6-17-2014 2-06-45 PM.png

The FormCalc logic caused my form to default to Airline Carrier “AA” and Carrier Name “American Airlines”.

6-17-2014 2-21-33 PM.png

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply