Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member

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.

Go to Edit, Form Properties, Variables tab.

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


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

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.

Here is the scripting for the CARRID event.

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. 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.

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".

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

Labels in this area