LiveCycle Designer Scripting Basics
LiveCycle Designer Scripting Basics
Contents
About This Document
Who should read this document? .......................................................................................................6
Purpose and scope .....................................................................................................................6
Additional information .................................................................................................................7
4. Events
Types of events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
Process events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
Interactive events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
4
Application events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
calculate event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
change event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
click event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
docClose event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
docReady event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
enter event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
exit event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
form:ready event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
full event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
indexChange event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
initialize event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
layout:ready event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
mouseDown event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
mouseEnter event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
mouseExit event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
mouseUp event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
postOpen event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
postPrint event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
postSave event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
postSign event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
postSubmit event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
preOpen event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
prePrint event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
preSave event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
preSign event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .41
preSubmit event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
validate event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
6. Variables
Naming variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
To define a text variable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
To view a text variable definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
To delete a text variable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
5
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .115
6
Additional information
Adobe has a wide variety of resources dedicated to Designer ES2 scripting focused at both the form author and the form developer
audiences. The following illustration and section outline the different resources available and where to find them.
User Forums
The Designer ES2 Forum is a meeting place for professionals who are interested in discussing issues related to Designer ES2. Respond to
reader questions, report bugs or issues with the product, or post questions of your own to other form designers and Adobe experts. For infor-
mation, see www.adobeforums.com.
LIVECYCLE DESIGNER ES2 8
About This Document LiveCycle Designer ES2 Scripting Basics
Scripting samples
The scripting samples are working forms or packages that include instructions on how the sample was created and any sample data used to
create and view the form. New samples are added on an ongoing basis by both Adobe experts and third-party organizations. See the samples
at www.adobe.com/devnet/livecycle/samples.html.
9
At a more advanced level, you can create your own functions tailored towards your own custom form processing needs.
Designer ES2 supports two scripting languages, each geared towards the needs of a particular type of form developer. FormCalc is a straight-
forward, easy-to-use calculation language that is modelled on common spreadsheet functionality. It includes a variety of built-in functions
designed to reduce the amount of time you need to spend developing your form design. JavaScript, a powerful scripting language, provides
you with a great deal of flexibility when creating your scripts and allows you to leverage any existing knowledge of the language.
Remember that scripting on a form is entirely optional. You can choose to take advantage of scripting to provide a richer user experience,
but many of the most powerful features available during form creation are available in Designer ES2 without the use of scripts. However,
through scripting, you can manipulate and control almost all aspects of your form design.
Note: You can also use the Action Builder dialog box on the Tools menu to build common interactive capabilities in forms that have a flowable
layout, without writing scripts.
Scripts associated with a particular event execute whenever that event occurs. Some events can occur multiple times within the same form
filling session. For example, the following script adds one to the current value of a numeric field:
NumericField1.rawValue = NumericField1.rawValue + 1;
If you add this script to the calculate event for NumericField1, when you open the form for the first time, NumericField1 displays the
value 2. This indicates that the calculate event occurred twice in the sequence of events that occurred when the form was opened.
Objects that support calculations and scripts Objects that do not support calculations and scripts
Barcodes Circle
Objects that support calculations and scripts Objects that do not support calculations and scripts
Image Field
List Box
Numeric Field
Password Field
Print Button
Radio Button
Reset Button
Subform
Text Field
Standard Object Library Object XML Form Architecture Object (Base) XML Form Architecture Object (UI)
Standard Object Library Object XML Form Architecture Object (Base) XML Form Architecture Object (UI)
Multiline view: A. Reference syntax B. Show Events for Child Object button C. Functions button D. Check Script Syntax button E. Script editing field
Show Lists all form design events that support user-defined scripting. Any events that do not apply to a particular object appear dimmed.
Events that contain a calculation or script display an asterisk (*) beside the name of the event.
LIVECYCLE DESIGNER ES2 12
About scripting in Designer ES2 LiveCycle Designer ES2 Scripting Basics
Show Events for Child Objects Displays the event you have currently selected in the Show list for the current object and all of its child
objects. If you select the uppermost object in the Hierarchy palette, this option displays the event you have currently selected in the Show
list for all objects on your form.
Functions Displays a list of available built-in FormCalc or JavaScript functions, depending on the scripting language you currently
have selected in the Language list.
To place a function onto your script editing field, select a function from the list and press Enter.
Check Script Syntax Checks all of the scripts in a form for correct syntax and reports any errors on the Warnings tab in the Report
palette.
Language Specifies the scripting language you want to use for the current calculation or script. Two options are available:
• FormCalc FormCalc is a native Adobe calculation language typically used for shorter scripts, such as simple calculations.
• JavaScript JavaScript is the default scripting language for new forms.
The scripting language that is displayed in the Language list matches the scripting language option you select as the default for new forms
in the Workspace panel in the Options dialog box. However, if you change the scripting language setting for the current form on the
Defaults tab in the Form Properties dialog box, the scripting language that is displayed in the Language list changes similarly for any
new scripts on new events. Changing the scripting language option in the Form Properties dialog box does not change the scripting
language for existing scripts. If an event already contains script and that script is deleted, the Script Editor continues to use that same
scripting language for the duration of your Designer ES2 working session.
See “To set the default scripting language for new forms” on page 13
Run At Specifies where the calculation or script will execute. Three options are available:
• Client Calculations and scripts execute while the client application (for example, Acrobat, Adobe Reader, or a web browser)
processes the form.
• Server Calculations and scripts execute while the server application (for example, Forms ES2) processes the form.
• Client and server Calculations and scripts execute while the server application (for example, Forms ES2) processes the form, except
in cases where the HTML client application supports client-side scripting. For example, a script that accesses a database to prefill
data on a form.
Enable Event Propagation Specifies that form events propagate to ancestor containers.
13
Warnings tab in the Report palette Displays target and warning marker messages as well as all JavaScript or FormCalc scripting syntax errors when you select
the Check Script Syntax command from the Tools menu or click the Check Script Syntax button in the Tools toolbar. For more
information, see “To check script syntax” on page 22.
When you double-click a syntax warning message in the Warnings tab, the script that contains the error is loaded into the
Script Editor, and the line with the error is highlighted.
You can also double-click a warning message to select the related object in the Design View and the Hierarchy palette, and
press F1 to display information about how to fix the warnings.
To check for JavaScript run-time errors, you can activate the JavaScript Console. For more information, see “JavaScript
Debugger in Acrobat Professional” on page 71.
Binding tab in the Report palette If you include fields on your form design that are bound to a data source, the Binding tab can assist you by displaying lists
of fields based on how you defined their data binding. For example, you can list only fields with Global Data Binding or only
those with no data binding defined. This feature is especially useful on forms that have a large number of data bound fields.
Log tab in the Report palette Displays validation messages, JavaScript or FormCalc scripting execution errors, and design-time form rendering errors
generated by Designer ES2 when you import or save a form, or preview a form using the Preview PDF tab.
LIVECYCLE DESIGNER ES2 15
Configuring LiveCycle Designer ES2 for Scripting LiveCycle Designer ES2 Scripting Basics
Hierarchy palette You can use the Hierarchy palette to determine the location of a form object for a reference syntax. The Hierarchy palette is
a graphical representation of the structure of a form. It displays the contents of the Master Pages and Design View tabs.
The Hierarchy palette also displays referenced objects under the Referenced Objects node. A referenced object is an object
that is added to a form only when it is required. Whenever data flows across multiple pages or content areas, the overflow
leader and trailer subforms are inserted into the form in the appropriate places.
Binding tab in the Object palette Every Designer ES2 object that can be bound to a data source includes a Binding tab in the Object palette. If you bind an
object on your form design to a particular data node from your data connection, the Data Binding (Open, Save, Submit) list
displays a valid FormCalc reference syntax for accessing that data node. You can use the FormCalc reference syntax in other
calculations or scripts for testing purposes.
XML Source tab The XML Source tab contains the form design’s XML code. The XML source code defines all aspects of the form. You can use
the XML Source tab to view the XML Form Object Model structure of a form design and to understand the relationships
between objects and properties. In the XML source, the XML element names are equivalent to the object names in the XML
Form Object Model, and attributes are equivalent to properties.
When you select an object in the Hierarchy palette and then click the XML Source tab, the first line of the corresponding
element is highlighted. The object name in Designer ES2, as listed in the Hierarchy palette, becomes the value of the name
attribute in the XML source.
You can set options in the Tools > Options dialog box for viewing the source in the XML Source tab, such as showing or
hiding line numbers and setting the syntax coloring.
It is recommended that you do not edit the XML source code directly.
You may also find it useful to change the default options for the Script Editor to make it easier to debug your calculations and scripts. These
options are in the Workspace panel of the Options dialog box, which is available by selecting Tools > Options and then selecting Workspace
from the list on the left. For example, you can choose to display line numbers in the Script Editor or change the formatting of FormCalc or
JavaScript syntax.
“Creating Calculations and Scripts” on page 16
“Events” on page 24
“Debugging Calculations and Scripts” on page 70
16
More complex forms can take advantage of scripting to perform data source connectivity and data manipulation at run time. For examples
of common scripting tasks, see “Examples of Common Scripting Tasks” on page 89.
Creating calculations and scripts in Designer ES2 involves following a general process each time you attach a calculation or script to an
object. Although not all aspects of the process are required each time you create a calculation or script, following the process helps to
eliminate potential errors and unexpected results.
In general, each time you create a calculation or script, you perform the following tasks:
• Select the object to which you want to attach a calculation or script. Although you can create calculations and scripts that manipulate
almost any object on your form design, not all form design objects support form events. For a list of standard objects included in the
Object Library palette in Designer ES2 that support scripting, see “Objects that support calculations and scripts” on page 9.
• Write your calculation or script in the script editing field of the Script Editor.
• Test the calculation or script either by using the Preview PDF tab or in your test environment.
However, subform objects already have an XML Form Object Model property named x that represents the horizontal position of the
subform on the form design.
To avoid naming conflicts, you need to choose field naming conventions that differ from the XML Form Object Model naming conventions.
For example, you can use any of the following field names for the text field in the example above:
LIVECYCLE DESIGNER ES2 17
Creating Calculations and Scripts LiveCycle Designer ES2 Scripting Basics
• horizontalValue
• x_value
• xLetter
• hValue
For more information and a list of the XML Form Object Model property, method, and object names, see LiveCycle Designer Scripting
Reference.
FormCalc JavaScript
Native Adobe calculation language valid in Designer ES2 and Forms ES2 Standard scripting language used in many popular software applications
Shorter scripts (typically one line only) Potential for longer scripts, if necessary, with the ability to use looping
Contains a variety of useful built-in functions to reduce the amount of scripting Provides access to the Acrobat Object Model and the JavaScript capabilities of
required to accomplish common form design tasks Acrobat
Support for international dates, times, currencies, and number formats Debugging possible by using the JavaScript debugger in Acrobat
Built-in URL functions for Post, Put, and Get allow web-based interactions Create custom functions for your own specific needs
Compatible on all Designer ES2 and Forms ES2 supported platforms Compatible on all Designer ES2 and Forms ES2 supported platforms
2 In the Script Editor, from the Show list, select one of the events that apply to the object. The event you choose specifies when the script
will execute. If you are writing a calculation or script that affects an object that does not support events, you must add your calculation
or script to a form design object that does support form events. For example, using the new button object, select the click event in the
Show list.
3 In the Language list, select your scripting language. For example, for the new button object, select JavaScript.
4 In the Run At list, select where you want the script to execute. For example, for the new button object, select Client.
You can choose to run calculations or scripts on your client-based application (for example Acrobat or a web browser) or on your server-
based process (for example, Forms ES2). When set to Client, processing of calculations and scripts initiates after the form renders. When
set to Server, processing of calculations and scripts initiates during the form rendering process. Previewing your form by using the
Preview PDF tab simulates opening the form in Acrobat; therefore, scripts set to run at Client or Client and Server execute.
Note: Selecting Client And Server from the Run At list causes a script to execute in either the client application or the server application,
depending on which application is used to process the form.
5 In the Script Source field, insert your FormCalc calculation or JavaScript script. You can take advantage of the statement completion
functionality of Designer ES2 to help you create reference syntaxes for your calculation or script. For example, add the following JavaS-
cript script to the new button object:
xfa.host.messageBox("Hello World!", "Creating a new script", 3);
6 After you complete your form design, test and debug your calculations and scripts before putting them into production. For example,
for the new button object, preview the PDF of the form using the Preview PDF tab. Click the button object to display the message box
specified in step 5.
For more information about the Designer ES2 objects that support scripting, see “Objects that support calculations and scripts” on
page 9.
Caution: Although it is possible to edit XML source code directly in the XML Source tab, it is recommended that you do not make any
changes unless you are familiar with the Adobe XML Forms Architecture. For more information about the XML Forms Architecture, see
www.adobe.com/devnet/livecycle/.
2 Select the method or property you want to apply for the form design object and continue writing the script. To close the statement
completion list without selecting a function, press the Esc key.
The list of available XML Form Object Model properties changes depending on the form design object or property that appears before
the period.
Note: The statement completion list appears only when accessing objects, properties, and methods in the XML Form Object Model. It does
not appear when working with standard JavaScript objects or methods.
• exit Initiates when the form filler changes the focus from a particular field, button, or subform, to another object.
• change Initiates when a form filler makes a change to a field value. This event is most commonly used with drop-down lists or list
boxes to execute a script when a form filler makes a change to the current value.
• click Initiates when a form filler clicks a field or button. This event is most commonly used with buttons to execute a script when a
form filler clicks the button.
To view a scripting event for a container object and its children in the Script Editor
1 If it is not already in multiline mode, expand the Script Editor to display multiple lines of script and ensure that the Show Events for
Child Objects option is selected.
2 Select a container object, such as a subform.
3 In the Show list, select a valid scripting event.
LIVECYCLE DESIGNER ES2 21
Creating Calculations and Scripts LiveCycle Designer ES2 Scripting Basics
The events appear in the script editing field of the Script Editor, separated by the reference syntax for each event. Note that certain events
only apply to specific types of objects. When you select a script event, the script editing field of the Script Editor only displays valid
instances of the event. For example, if you select a subform that contains a drop-down list and select the preOpen event, the Script editor
displays a single entry representing the drop-down list. This is because the preOpen event only applies to drop-down lists. Alternatively,
selecting the enter event displays two entries, one for the drop-down list and one for the subform.
Note: The Show list denotes events that contain scripts using a trailing asterisk (*) after the name of the event. If an event contains a script,
when you select the event from the Show list, the source appears in the script editing field of the Script Editor.
To view all scripting events for a single object in the Script Editor
1 Select an object in your form.
2 In the Show list, select All Events.
The events appear in the script editing field of the Script Editor, separated by the reference syntax for each event.
To view all scripting events for a container object and its children in the Script Editor
1 If it is not already in multiline mode, expand the Script Editor to display multiple lines of script and ensure the Show Events for Child
Objects option is selected.
2 Select a container object, such as a subform.
3 In the Show list, select All Events.
The events appear in the script editing field of the Script Editor, separated by the reference syntax for each event.
To view all scripts for a container object and its children in the Script Editor
1 If it is not already in multiline mode, expand the Script Editor to display multiple lines of script and ensure that the Show Events for
Child Objects option is selected.
2 Select a container object, such as a subform. All events for the container object and any child objects appear in the Script Editor.
3 In the Show list, select All Events.
The scripts appear in the script editing field of the Script Editor, separated by the reference syntax for each event.
Another example of using the host model and event model methods is to obtain the value of a field on an interactive form before a user
manually changed it. This is useful for observing how the objects on your form design respond to user-entered data:
xfa.host.messageBox(xfa.event.prevText) // FormCalc
xfa.host.messageBox(xfa.event.prevText); // JavaScript
...
var oDB = xfa.sourceSet.nodes.item(nIndex);
...
// Search node with the class name "command"
var nDBIndex = 0;
while(oDB.nodes.item(nDBIndex).className != "command")
nDBIndex++;
oDB.nodes.item(nDBIndex).query.recordSet.setAttribute("stayBOF", "bofAction");
oDB.nodes.item(nDBIndex).query.recordSet.setAttribute("stayEOF", "eofAction");
To clone the sourceSet model, you need to change the line that accesses it by appending the clone (1) method to the end of the statement:
var oDB = xfa.sourceSet.nodes.item(nIndex).clone(1);
Note: You can store the cloned data connection node in a variable or a variable defined in a script object.
24
4. Events
Every calculation or script you attach to a form object is associated with a specific event. An event is defined as a particular occurrence or
action that can change the state of a form and, when the change of state occurs, automatically invoke a calculation or script associated with
the event. Events occur at various times, from the beginning of the form rendering process when merging data with a form design, all the
way through to a form filler interacting with objects on a form in a client application. By applying calculations and scripts to specific events,
you can control every aspect of how you present form objects, as well as form data, and how the objects and data respond to form filler inter-
action.
A single change of state or form filler action may trigger multiple events. For example, tabbing from the current field to the next field triggers
both the exit event for the current field and the enter event for the next field. If the current and next fields are in different subforms, a
total of four events are triggered; namely, exit events for the current field and subform, and enter events for the next field and subform.
In general, each of the different categories of form events follow a predictable ordering.
Types of events
Form events fall into one of the following categories:
Process events This type of event initiates automatically as the result of an internal process or action related to objects on a form. For
example, if a form filler clicks a button that adds a new page to the form, the initialize, calculate, validate, and layout:ready
process events initiate automatically for the new page.
Interactive events This type of event initiates as a direct result of form filler actions. For example, if a form filler moves the pointer over a
field on a form, the mouseEnter event initiates in response to the action.
Application events This type of event initiates as a result of the actions that either a client application or a server application performs. For
example, you can create a calculation or script to perform a task immediately after the form is saved by using the postPrint event.
Process events
Process events initiate automatically as the result of an internal process or action related to a form or objects on a form. These events initiate
immediately following significant form changes; for example, after a form design is merged with data or after the form pagination process
finishes. Process events also initiate immediately after interactive events initiate. For example, immediately after any interactive event
initiates, the calculate event initiates followed by the validate event.
The following list contains the process events, which are available from the Show list in the Script Editor:
• calculate
• form:ready
• indexChange
• initialize
• layout:ready
• validate
Process events can initiate many times as a result of dependencies; that is, actions associated with a single event that ultimately initiates one
or more additional events. Using an example of a form filler clicking a button to reveal a previously hidden portion of the form, after the
form filler clicks the button, not only does a series of interactive and processing events initiate for the button itself, but a number of process
events for the new subform initiates as well.
LIVECYCLE DESIGNER ES2 25
Events LiveCycle Designer ES2 Scripting Basics
The following image represents the general flow of events leading up to a PDF form opening in Acrobat or Adobe Reader.
After the form opens in Acrobat or Adobe Reader, these process events may still initiate as the result of changes made to the form. For
example, the calculate, validate, and layout:ready events for an object initiate immediately after some interactive events occur;
therefore, calculations and scripts attached to the processing events will run multiple times.
Interactive events
Interactive events initiate as a direct result of form filler actions, which makes these events useful for a variety of calculation and scripting
tasks. For example, you can add a script to the mouseEnter event for a text field that changes the border color of the field to blue and a script
to the mouseExit event that changes the border color back to the original color. This action creates a highlighting effect when form fillers
move the pointer over the field to visually assist them while filling the form. Interactive events are also useful for changing form data in
response to a form filler selection. For example, you can add a script to the change event for a drop-down list that updates the data values
in multiple fields in response to the value the form filler selects in the drop-down list.
The following list contains the interactive events, which are available from the Show list in the Script Editor:
• change
• click
• enter
• exit
• mouseDown
• mouseEnter
• mouseExit
• mouseUp
• postOpen
• postSign
• preOpen
• preSign
The following image displays the general flow of events for form fillers who use the mouse to select an object and change its value.
LIVECYCLE DESIGNER ES2 26
Events LiveCycle Designer ES2 Scripting Basics
Note: This image provides a general flow of events; however, certain form filler actions and form objects can cause alternate event ordering. For
example, if a form filler selects a value from a drop-down list, the mouseExit event occurs after the click event but before the change or full
events. Similarly, if a form filler selects a field, holds down the mouse button, and then exits the field while still holding down the mouse button,
the mouseUp event occurs out of the order described in this image.
LIVECYCLE DESIGNER ES2 27
Events LiveCycle Designer ES2 Scripting Basics
The following image displays the general flow of events for form fillers who use the keyboard to select an object and change its value.
Application events
Application events initiate as a result of the actions that a client application or a server application perform, either due to a form filler action
or an automated process. Application events do not exist as part of a general flow of events. They are single events that correspond to actions
that the client or server application performs.
The following list contains the processing events, which are available from the Show list in the Script Editor:
• docClose
• docReady
• postPrint
• postSave
• postSubmit
• prePrint
• preSave
• preSubmit
LIVECYCLE DESIGNER ES2 28
Events LiveCycle Designer ES2 Scripting Basics
For example, the following image displays the general flow of events for the preSave event.
If a form filler saves the form in Acrobat or Adobe Reader, the preSave event initiates immediately before the save operation, followed by
the calculate, validate, and layout:ready events, in that sequence for all objects on the form. The same event sequence initiates if the
form contains a script that programmatically saves the form.
A similar sequence of events occurs for each of the other application events previously listed.
calculate event
Description
Initiates in the following situations:
• When your form design and data merge into your finished form.
• When a change occurs to any value that the calculation is dependent on, such as the value of a particular field, unless the form filler has
manually overridden the calculated value. As a result, the object will display the return value of the event. The properties for manually
overridden fields are located in the Value tab of the Object palette.
• When a field loses focus; for example, when a form filler clicks or uses the Tab key to exit a field.
When using the calculate event to perform calculations or scripts, consider the following potential issues:
• Calculations and scripts on the calculate event must not make any changes to the structure of the form, except for the form field and
data values.
• Content inserted by the calculate event must conform to the associated validations for the object; otherwise, validation errors will
occur.
• Calculations and scripts must not include an infinite loop because it causes the form to update the value continuously. For example, a
script that increments the value of a field as part of a looping expression, such as a while or for loop, could create an infinite loop.
• The last expression evaluated in the calculate event is used to populate the value of the current form object. For example, if the script
on the calculate event first sets the value of the current field to 500 and then sets the value of another field to 1000, both fields will
display the value 1000 at run time. As a result, you need to limit the scripting that you add to the calculate event to those that deal
specifically with setting the value of the current field.
LIVECYCLE DESIGNER ES2 29
Events LiveCycle Designer ES2 Scripting Basics
Type
Processing event
Support
Version
XFA 2.1
Example
Use the calculate event for updating numeric values in fields because this event initiates immediately after most other events. For example,
on a purchase order form, you can use the calculate event for a field to determine the percentage of sales tax due based on the cost of the
order. The calculation will initiate every time a change is made to the values in the form fields, ensuring that the value displayed for the sales
tax is always correct.
However, because the calculate event can initiate many times, you must ensure that the calculation or script you add to the event will not
cause data values to increment unnecessarily. For example, if your sales tax calculation adds the value of the sales tax to the total cost each
time the calculate event initiates, the resulting total cost value on your form may be too large.
For a detailed example of using the calculate event, see “Calculating the field sums” on page 101.
change event
Description
Initiates when a form filler changes the content of a field by performing one of these actions:
• Types a keystroke providing the field has keyboard focus
• Pastes data into the field
• Makes a selection from a list box or drop-down list
• Selects or deselects a check box
• Changes the setting of a group of radio buttons
This event does not initiate in response to changes in the object values as a result of calculations or scripts, or by the merging of the form
design with data.
Type
Interactive event
Support
Version
XFA 2.1
LIVECYCLE DESIGNER ES2 30
Events LiveCycle Designer ES2 Scripting Basics
Example
Use this event for any calculations or scripts that must initiate in response to a form filler changing the value of a field. For example, you can
use the change event for a drop-down list to highlight specific rows in a table. Using this technique, each time the form filler selects a value
in the drop-down list, the corresponding row of the table appears highlighted.
Note: Scripting against an object's 'this.rawValue' does not work. Use the event model property $event.fullText instead to get the
object's current value.
For a detailed example of using the change event, see “Getting the current or previous value of a drop-down list” on page 99.
click event
Description
Initiates when a mouse click occurs within the region. When a click event initiates for a text or numeric field, calculations or scripts execute
immediately. However, the value of the field does not change in response to calculations and scripts until the field loses focus.
Note: You cannot place a calculation or script on the click event of a submit button because the calculation or script will override the
submission action. Instead, place any calculations and scripts on the preSubmit event for a submit button.
For more information about form submission actions, see the Designer ES2 Help.
Type
Interactive event
Support
Version
XFA 2.1
Example
Use this event for performing an action as a direct response to a form filler clicking a button or selecting a radio button or check box on a
form. For example, you can use the click event for a check box to hide and show a field on the form.
For a detailed example of using the click event, see “Changing the visual properties of an object on the client” on page 96.
docClose event
Description
Initiates at the very end of processing a form, only if all form validations complete with no errors.
Type
Application event
LIVECYCLE DESIGNER ES2 31
Events LiveCycle Designer ES2 Scripting Basics
Support
HTML browser no
Version
XFA 2.1
Example
This event initiates too late to modify a saved form and is intended to provide the ability to generate an exit status or completion message.
For example, you can use the docClose event to display a message to a form filler indicating that the form is completed.
docReady event
Description
Initiates immediately after the form opens in Acrobat or Adobe Reader.
Type
Application event
Support
HTML browser no
Version
XFA 2.1
Example
This event is the first one that initiates after the form opens in Acrobat or Adobe Reader. Any calculation or scripting tasks that require the
full form, or that should only run once when the form filler first opens the form, should use this event. For example, you can use the
docReady event to check the version of Acrobat or Adobe Reader and return a message to the form filler if the form filler must upgrade the
application before filling the form.
enter event
Description
Initiates when a field or subform gains keyboard focus, whether caused by a form filler action (tabbing into a field or clicking in it) or by a
script programmatically setting the focus.
Type
Interactive event
LIVECYCLE DESIGNER ES2 32
Events LiveCycle Designer ES2 Scripting Basics
Support
Version
XFA 2.1
Example
You can use this event to provide help text or other messages to a form filler while entering the current field or subform. For example, if a
field requires a value in a specific format, or if filling a field requires special instructions, you can use this event to provide a message to the
form filler indicating the special needs.
For a detailed example of using the enter event, see “Highlighting fields in response to form filler interaction” on page 102.
exit event
Description
Initiates when the field or subform loses keyboard focus, whether caused by a form filler action (tabbing to another field or clicking outside
it) or by a script programmatically removing the focus.
Note: If the purpose of your script is to manipulate the value of the current field, you need to consider attaching your script to the calculate
event.
Type
Interactive event
Support
Version
XFA 2.1
Example
You can use this event to provide verification of field data as a form filler moves the focus away from a field. For example, if a field requires
a value, you can use this event to provide a message to the form filler indicating that the field requires some data before the form can be
submitted.
For a detailed example of using the exit event, see “Highlighting fields in response to form filler interaction” on page 102.
form:ready event
Description
Initiates after the form design and data are merged, the finished form exists in memory, and the initialize, calculate, and validate
events are complete.
LIVECYCLE DESIGNER ES2 33
Events LiveCycle Designer ES2 Scripting Basics
Note: The form:ready event only applies to Design View objects, and does not apply to Master Page objects (see “Process events” on page 24).
Type
Processing event
Support
HTML browser no
Version
XFA 2.1
Example
You can use this event to perform tasks after the form design and data are merged but before the layout is established. For example, you can
use this event to customize the ordering or placement of subforms on your form before the form is paginated and rendered.
full event
Description
Initiates when the form filler attempts to enter more than the maximum allowed amount of content into a field. For example, if the Limit
Length property for a field is set to 5, and a form filler attempts to enter the string abcdef, the full event initiates when the form filler types
the letter f.
Note: The Limit Length property for a field is located in the Field tab in the Object palette.
Type
Interactive event
Support
HTML browser no
Version
XFA 2.1
Example
Use this event to indicate to a form filler that a field has reached its maximum capacity. For example, you can output a message to the form
filler indicating that the field is full and provide any steps that should be taken to correct the issue.
indexChange event
Description
Initiates as a result of a subform being inserted, moved, or removed from the form by merging new data with the form or by using scripting.
Keep in mind that the indexChange event does not fire when deleting the last row of a table.
LIVECYCLE DESIGNER ES2 34
Events LiveCycle Designer ES2 Scripting Basics
Note: This event is received only by the subform instances that are controlled by the instance manager; the event is ignored for subform sets.
Type
Processing event
Support
HTML browser no
Version
XFA 2.5
Example
You can use this event to set properties based on the instance value of a particular object. For example, you can use this event to coordinate
the shading of alternate rows in a table.
initialize event
Description
Initiates for all objects after the form design is merged with data.
Type
Processing event
Support
Client application Availability
Version
XFA 2.1
Example
You can use this event to perform actions when an object is first created, either as the result of a form filler action or during the form creation
process. For example, you can use this event to control settings for new instances of a subform object that a form filler adds to the form by
using a button.
layout:ready event
Description
Initiates after the form design and data are merged, the form exists, and the form’s layout is applied. At this time, the finished form has not
been rendered; therefore, a calculation or script set to run on this event could modify the layout before the form is rendered. This event also
occurs after the form is rendered if a calculation or script changes the data or causes a change to the form in Acrobat or Adobe Reader.
LIVECYCLE DESIGNER ES2 35
Events LiveCycle Designer ES2 Scripting Basics
Note: Scripts that fire on layout:ready should not do anything that would cause the layout of the form to change. For example, this would include
anything involving subforms or tables that grow or shrink, adding fragments dynamically at run time, adding or removing subform instances,
and toggling the presence setting of an object between hidden and visible.
Note: Fields in interactive forms that contain the layout:ready event are supported in Acrobat 7.0.5 and later.
Type
Processing event
Support
HTML browser no
Version
XFA 2.1
Example
You can use this event to perform tasks immediately after the form layout is established. For example, you can use this event to determine
the number of pages the form contains.
mouseDown event
Description
Initiates when a form filler presses the mouse button at the same time that the pointer is within a field.
Note: When a mouseDown event initiates for a text or numeric field, calculations or scripts run immediately. However, the value of the field does
not change in response to calculations and scripts until the field loses focus. When a mouseDown event initiates for a signature field, the event
initiates before the signature process begins.
Type
Interactive event
Support
Version
XFA 2.1
Example
You can use this event to perform an action as a direct response to a form filler clicking a button, or selecting a radio button or check box
on a form. For example, you can use the mouseDown event for a check box to hide and show a field on the form. This event is conceptually
similar to the click event and has a similar purpose.
LIVECYCLE DESIGNER ES2 36
Events LiveCycle Designer ES2 Scripting Basics
mouseEnter event
Description
Initiates when the form filler moves the pointer into the area of the field, without necessarily pressing the mouse button. This event is not
initiated when the pointer moves into the field for a different reason; for example, because an overlapping window closes.
Type
Interactive event
Support
HTML browser no
Version
XFA 2.1
Example
You can use this event to provide visual feedback to a form filler in conjunction with the mouseExit event. For example, you can use this
event to change the border or background color of an object to help visually indicate to form fillers that they are working in a specific field.
For a detailed example of using the mouseEnter event, see “Highlighting fields in response to form filler interaction” on page 102.
mouseExit event
Description
Initiates when a form filler moves the pointer out of the field, even if the form filler is pressing the mouse button. It is not initiated when the
pointer moves out of the field for a different reason; for example, because an overlapping window opens.
Type
Interactive event
Support
HTML browser no
Version
XFA 2.1
Example
You can use this event to provide visual feedback to a form filler in conjunction with the mouseEnter event. For example, you can use this
event to return the border or background color of an object to its original value to help visually indicate to form fillers that they are no longer
working in a specific field.
For a detailed example of using the mouseExit event, see “Highlighting fields in response to form filler interaction” on page 102.
LIVECYCLE DESIGNER ES2 37
Events LiveCycle Designer ES2 Scripting Basics
mouseUp event
Description
Initiates when a form filler releases the mouse button at the same time that the pointer is within a field.
Note: When a mouseUp event occurs for a text or numeric field, calculations or scripts run immediately. However, the value of the field does not
change in response to calculations and scripts until the field loses focus.
Type
Interactive event
Support
Version
XFA 2.1
Example
You can use this event to perform actions as a direct response to a form filler clicking a button, or selecting a radio button or check box on
a form. For example, you can use the mouseUp event for a check box to hide and show a field on the form. This event is conceptually similar
to the click event and has a similar purpose.
postOpen event
Description
Initiates immediately after a form filler performs an action that causes the data in a drop-down list to appear, such as clicking the arrow icon
on the drop-down list or tabbing into the drop-down list and then using the down arrow. This event initiates after the contents of the drop-
down list are displayed.
Note: This event applies only to the Drop-down List object.
Type
Interactive event
Support
HTML browser no
Version
XFA 2.8
LIVECYCLE DESIGNER ES2 38
Events LiveCycle Designer ES2 Scripting Basics
Example
You can use this event to handle errors or unexpected outcomes as a result of processing the opening of the drop-down list. For example, if
the preOpen event is dispatched via scripting instead of user interaction, or if the opening of the drop-down list data does not occur as a
result of an error, the postOpen event is still dispatched to let error handling scripts execute.
postPrint event
Description
Initiates immediately after the rendered form is sent to the printer, spooler, or output destination.
Type
Application event
Support
HTML browser no
Version
XFA 2.1
Example
You can use this event to display information messages to the form filler after the form is printed. For example, you can create a script on
the postPrint event to remind form fillers what steps they need to take to submit the form by hand.
postSave event
Description
Initiates immediately after a form filler saves a form in PDF or XDP format. This event does not initiate when you export a subset of the
form (for example, only form data) to XDP.
Type
Application event
Support
HTML browser no
Version
XFA 2.1
Example
You can use this event to display information messages to the form filler after the form data is saved. For example, you can create a script on
the postSave event to remind form fillers how much time remains for them to successfully complete and submit the form.
LIVECYCLE DESIGNER ES2 39
Events LiveCycle Designer ES2 Scripting Basics
postSign event
Description
Initiates immediately after a form filler performs an action that applies a digital signature to a form.
Note: This event applies only to the Signature Field object.
Type
Interactive event
Support
HTML browser no
Version
XFA 2.8
Example
You can use this event to inform a user about any restrictions that are imposed now that the form is digitally signed.
postSubmit event
Description
Initiates immediately after a form submits data to the host through the HTTP protocol.
Note: This event does not distinguish between submissions that are initiated by instances of clicking buttons, or submissions made to different
URLs. Any script that needs to make these distinctions must include a script to determine which button was clicked. In general, the postSubmit
event is conceptually similar to the postSave event and serves a similar purpose.
Type
Application event
Support
Version
XFA 2.8
Example
You can use this event to perform actions immediately after the form data is submitted. For example, you can create a script on the
postSubmit event to display confirmation that the submission performed successfully.
LIVECYCLE DESIGNER ES2 40
Events LiveCycle Designer ES2 Scripting Basics
preOpen event
Description
Initiates when a form filler performs an action that causes the drop-down list to appear, such as clicking the arrow icon on the drop-down
list or by tabbing into the drop-down list and using the down arrow. This event initiates before the contents of the drop-down list are
displayed.
Note: This event applies only to the Drop-down List object.
Type
Interactive event
Support
HTML browser no
Version
XFA 2.4
Example
You can use this event to control the loading of large numbers of list items. For example, you can use this event to load a fixed number of
records from a data source into a drop-down list. This improves the performance of the form for the form filler at run time.
prePrint event
Description
Initiates immediately before the process of rendering a form for printing begins. You cannot cancel printing using this event.
Caution: Avoid using this event to hide or show form objects. For example, if a form filler has already digitally signed the form, using this event
to hide all button objects prior to printing will impact the state of the signature.
Type
Application event
Support
Version
XFA 2.1
Example
You can use this event to change the presence of an object to prevent it from printing. For example, you can use this event to hide text or
instructions intended for the form filler to use while filling the form online.
LIVECYCLE DESIGNER ES2 41
Events LiveCycle Designer ES2 Scripting Basics
preSave event
Description
Initiates immediately before form data is saved in PDF or XDP format. This event does not initiate when the form data or another subset of
the form is exported to XDP.
Type
Application event
Support
Version
XFA 2.1
Example
You can use this event to change form data immediately before the data is saved. For example, you can create a script on the preSave event
to scan the data and display a reminder message to the form filler if certain required fields remain empty.
preSign event
Description
Initiates immediately before a form filler performs an action that applies a digital signature to a form.
Note: This event applies only to the Signature Field object.
Type
Interactive event
Support
Client application Availability
HTML browser no
Version
XFA 2.8
Example
You can use this event to validate the data that the digital signature covers or to provide any information to a user before they apply the digital
signature.
LIVECYCLE DESIGNER ES2 42
Events LiveCycle Designer ES2 Scripting Basics
preSubmit event
Description
Initiates when a form submits data to the host through the HTTP protocol. At this point, the data is organized into a data set but has not
been sent to the host. Calculations and scripts associated with this event can examine and alter the data prior to the form submission. If the
calculation or script is set to run on the server, the form sends the data to the server indicating that it should run the calculation or script
before performing any additional processing.
Note: This event does not distinguish between submissions initiated by instances of clicking buttons or to different URLs. Any script that needs
to make these distinctions must include code to determine which button was clicked. In general, the preSubmit event is conceptually similar to
the preSave event and serves a similar purpose.
Type
Application event
Support
Version
XFA 2.1
Example
You can use this event to change form data immediately before the data is submitted. For example, you can create a script on the preSubmit
event to scan the amount of data and display a message to the form filler estimating how long the data submission may take.
validate event
Description
Initiates when the form design and data merge to create your form and when a field loses focus; for example, when a form filler clicks or
uses the Tab key to exit a field. This event initiates again each time the value of a field changes. Calculations and scripts placed on the
validate event provide a method to perform validations that are more specific than those available through the Value tab of the Object
palette.
Calculations and scripts on the validate event are required to return true or false (expressed in a format appropriate to the scripting
language) corresponding to a validation that succeeds or fails, and must not affect the overall form structure of form values. In addition,
calculations and scripts should not attempt to provide feedback to a form filler because that form filler may not be using the form in a client
application such as Acrobat.
Note: Because validations are performed against the content of the form, they cannot be used to verify presentation formatting caused by field
patterns.
Type
Processing event
LIVECYCLE DESIGNER ES2 43
Events LiveCycle Designer ES2 Scripting Basics
Support
Version
XFA 2.1
Example
You can use this event to verify object values, particularly in situations where object data must conform to specific rules. For example, you
can create a script on the validate event to verify that a total cost field on a purchase order form does not have a negative value.
For a detailed example of using the validate event, see “Setting a field as required at run time” on page 101.
44
Apr(n1, n2, n3) Returns the annual percentage rate for a loan. None
At(s1, s2) Locates the starting character position of a string within String.search(s1)
another string.
Avg(n1 [, n2... ] ) Evaluates a set of number values and/or expressions and None
returns the average of the non-null elements contained
within that set.
Concat(s1 [, s2... ] ) Returns the concatenation of two or more strings. String.concat(s1, s2 [, s3 ... ])
Count(n1 [, n2...]) Evaluates a set of values and/or expressions and returns None
the number of non-null elements contained within the
set.
CTerm(n1, n2, n3) Returns the number of periods needed for an invest- None
ment earning a fixed, but compounded, interest rate to
grow to a future value.
Date() Returns the current system date as the number of days Date.getDate()
since the epoch.
The JavaScript Date object does not use the
epoch as a reference point.
Date2Num(d1 [, f1 [, k1 ] ] ) Returns the number of days since the epoch, given a The JavaScript Date object does not use the
date string. epoch as a reference point.
DateFmt([ n1 [, k1 ] ] ) Returns a date format string, given a date format style. None
Floor(n1) Returns the largest whole number that is less than or Math.floor(n1)
equal to the given value.
LIVECYCLE DESIGNER ES2 45
Scripting with FormCalc and JavaScript LiveCycle Designer ES2 Scripting Basics
Format(s1, s2) Formats the given data according to the specified None
picture format string.
FV(n1, n2, n3) Returns the future value of consistent payment amounts None
made at regular intervals at a constant interest rate.
IPmt(n1, n2, n3, n4, n5) Returns the amount of interest paid on a loan over a set None
time.
IsoDate2Num(d1) Returns the number of days since the epoch, given a None
valid date string.
Left(s1, n1) Extracts a specified number of characters from a string, String.substring(n1, n2)
starting with the first character on the left.
Ltrim(s1) Returns a string with all leading white space characters None
removed.
You can use JavaScript regular expressions to
perform this operation.
Max(n1 [, n2... ] ) Returns the maximum value of the non-null elements in Math.max(n1, n2)
the given set of numbers.
Min(n1 [, n2... ] ) Returns the minimum value of the non-null elements of Math.min(n1, n2)
the given set of numbers.
Mod(n1, n2) Returns the modulus of one number divided by another. Use the modulo (%) operator.
NPV(n1, n2 [, ... ] ) Returns the net present value of an investment based on None
a discount rate and a series of periodic future cash flows.
Num2Date(n1[, f1 [, k1 ] ] ) Returns a date string given a number of days since the None
epoch.
Num2GMTime(n1 [,f1 [, k1 ] ] ) Returns a GMT time string given a number of millisec- None
onds from the epoch.
Oneof(s1, s2 [, s3... ] ) Returns true (1) if a value is in a given set and false (0) if it None
is not.
This function is similar to the
String.search(s1) method and
String.match(expression) method.
LIVECYCLE DESIGNER ES2 46
Scripting with FormCalc and JavaScript LiveCycle Designer ES2 Scripting Basics
Parse(s1, s2) Analyzes the given data according to the given picture None
format.
Pmt(n1, n2, n3) Returns the payment for a loan based on constant None
payments and a constant interest rate.
PPmt(n1, n2, n3, n4, n5) Returns the amount of principal paid on a loan over a None
period of time.
PV(n1, n2, n3) Returns the present value of an investment of periodic None
constant payments at a constant interest rate.
Rate(n1, n2, n3) Returns the compound interest rate per period required None
for an investment to grow from present to future value in
a given period.
Replace(s1, s2 [, s3 ] ) Replaces all occurrences of one string with another String.replace(s1, s2)
within a specified string.
Right(s1, n1) Extracts several characters from a given string, begin- String.substring(n1, n2)
ning with the last character on the right.
Rtrim(s1) Returns a string with all trailing white space characters None
removed.
You can use JavaScript regular expressions to
perform this operation.
Sum(n1 [, n2... ] ) Returns the sum of the non-null elements of a given set None
of numbers.
Term(n1, n2, n3) Returns the number of periods required to reach a given None
future value from periodic constant payments into an
interest-bearing account.
Time() Returns the current system time as the number of milli- Date.getTime()
seconds since the epoch.
The JavaScript Date object does not use the
epoch as a reference point.
Within(s1, s2, s3) Returns true (1) if the test value is within a given range, String.search(s1)
and false (0) if it is not.
Using FormCalc
FormCalc is a simple yet powerful calculation language modeled on common spreadsheet software. Its purpose is to facilitate fast and
efficient form design without requiring a knowledge of traditional scripting techniques or languages. Using several of the built-in functions,
inexperienced FormCalc users can quickly create forms that save users from performing time-consuming calculations, validations, and
other verifications. This way, you can create a basic set of rules for the form design that allows the resulting form to react according to the
data it comes into contact with.
Within Designer ES2, FormCalc is the default scripting language in all scripting locations with JavaScript as the alternative. For information
on setting your default scripting language, see “Configuring the Designer ES2 workspace for Scripting” on page 11.
Caution: If you are developing forms for use with a server-based process (for example, using Forms ES2), with the intent of rendering your forms
in HTML, you should develop your calculations and scripts in JavaScript. FormCalc calculations are not valid in HTML browsers, and are
removed prior to the form being rendered in HTML.
FormCalc treats each new line in the Script Editor as a new expression to evaluate.
n A valid numeric value. Notice that the range of valid values varies from function to function.
[ [ n [, k ] ] ] No values are required, but you can choose to specify just n, or both n and k.
n1 [, n2 ... ] n1 is required, but you can choose to specify an unlimited number of additional values.
For more information and examples of valid syntax notation values, see the appropriate FormCalc functions in Designer ES2 Help.
Each simple expression evaluates to a single value by following a traditional order of operations, even if the order is not always obvious from
the expression syntax. For example, the following sets of expressions produce equivalent results.
2 - 3 * 10 / 2 + 7 2 - (3 * 10 / 2) + 7 -6
As implied in the previous table, all FormCalc operators carry a certain precedence when they appear within expressions. The following
table illustrates this operator hierarchy.
Precedence Operator
Highest =
(Unary) - , + , not
*,/
+,-
== , <> , eq , ne
& , and
Lowest | , or
All the previous examples are valid, simple expressions that you can add to a form field or object that accepts calculations and scripts. For
example, if you create a form in Designer ES2 with a single numeric field, add the following calculation to the calculate event in the Script
Editor.
LIVECYCLE DESIGNER ES2 50
Scripting with FormCalc and JavaScript LiveCycle Designer ES2 Scripting Basics
Then, when you click the Preview PDF tab to view the completed form, the value of the simple expression appears in the text field.
If the value does not appear in the preview, ensure that your simple expression appears in the calculate event of the form design object. Also,
ensure that you installed Designer ES2 and Acrobat correctly.
Using JavaScript
To allow form designers more flexibility and scripting power, Designer ES2 supports the use of JavaScript version 1.6 or earlier in all situa-
tions that support scripting.
Form developers who are familiar with JavaScript can apply their existing expertise directly to Designer ES2. Designer ES2 provides several
properties and methods that enhance JavaScript so that you to access field and object values. These properties and methods combined with
the Designer ES2 reference syntax provide you with easy manipulation of form values and data.
Note: The Script Editor does not provide syntax error checking for scripts created using JavaScript. In addition, statement completion options do
not appear for standard JavaScript objects or methods.
This table outlines the key concepts for developing scripts in JavaScript for Designer ES2. The table also provides the location for more infor-
mation on each concept within the Designer ES2 Help.
Creating references to object properties and values, including using the “Referencing object properties and values” on page 58
resolveNode method.
“To use statement completion to create calculations and scripts” on page 19
Using the host and event models to test and debug your form. “Testing and debugging calculations and scripts” on page 22
Using a script object to reuse your existing JavaScript functions. “Creating and Reusing JavaScript Functions” on page 66
In addition to the resources available in the Designer ES2 Help, the LiveCycle Developer Center contains extensive scripting resources and
documentation.
The scope in the following example is valid because var nFooVar = nOutsideVar inside the curly brackets can see var nOutsideVar =
2 outside the curly brackets.
In contrast, the following example shows an invalid scope because var nOutsideVar = nFooVar cannot access var nFooVar =4 within
the curly brackets.
Scope in scripting describes pieces of scripts that can access pieces. The pieces of script can be variables or functions.
You do not type inside.outside because you must access the outermost subform first and drill inwards.
<subform name="b"/>
In forms targeted for Acrobat or Adobe Reader 8.0, the SOM expression a.b.a returns the subform a. In forms targeted for Acrobat or
Adobe Reader 8.1, the SOM expression a.b.a returns null because subform b does not have a child named a. In Acrobat or Adobe Reader
9.0 or later, the expression returns an error because a is not a valid child of b.
In Acrobat or Adobe Reader 8.1, functions and variable within a node’s script do not become global (script objects being the exception) as
shown in this example:
<field name="field1">
event activity="initialize">
<script contentType="application/x-javascript">
function bar()
return "bar";
</script>
</event>
/field>
field name="field2">
<event activity="click">
<script contentType="application/x-javascript">
field1.bar();
</script>
</event>
</field>
When you click field 2 in a form targeting Acrobat or Adobe Reader 8.0, the function bar() executes.
When you click field 2 in a form targeting Acrobat or Adobe Reader 8.0, the function bar() does not execute. The reason is because
function bar() is available only from within the initialized script of field1.
LIVECYCLE DESIGNER ES2 54
Scripting with FormCalc and JavaScript LiveCycle Designer ES2 Scripting Basics
6. Variables
You can define form variables in Designer ES2 to store specific information in a central, accessible location. A variable typically acts as a
placeholder for text that you might have to change in the future. Form variables in Designer ES2 are always of the type "string". For example,
a variable can store the text of a message box title. When the text needs to change, all you have to do is open the affected form or template
and update the text once through the variable definition. Designer ES2 automatically propagates the new text across all instances of the
inserted variable.
Keep in mind that form variables are defined outside of the Script Editor, and are accessible by scripts on all objects on a form, as opposed
to scripting variables that you create in a specific FormCalc or JavaScript script.
You can create, view, and delete variables without using scripting. However, you must use scripting to access the values stored by variables
and manipulate them, or to apply the values to objects on your form.
Note: Form variable values reset each time you open a form.
Before you create a variable, decide the name of the variable and the text that it will contain. Variable definitions are saved with the form or
template.
Naming variables
At run time, naming conflicts occur when the names of variables are identical to those used as XML Form Object Model properties,
methods, or form design field names. These conflicts can cause scripts to return unexpected values; therefore, it is important to give each
variable a unique name. Here a couple of examples:
• Use the variable name fieldWidth and fieldHeight instead of x and y.
• Use the form design object name clientName instead of name.
Note: Variable names are case-sensitive and should not contain spaces.
firstName Tony
lastName Blue
age 32
In FormCalc, you can access the variable values in the same manner that you access field and object values. In this example, the values are
assigned to three separate fields:
TextField1 = firstName
TextField2 = lastName
NumericField1 = age
You can also use variables in FormCalc functions in the same way, as shown in this example:
Concat( "Dear ", firstName, lastName )
LIVECYCLE DESIGNER ES2 57
Variables LiveCycle Designer ES2 Scripting Basics
In JavaScript, you reference variable values by using the .value property instead of the .rawValue property that is used for field and object
values, as shown in this example:
TextField1.rawValue = firstName.value;
58
Note: By default, the subform object that represents the first page of a new form is unnamed. In the reference syntax above, the unnamed subform
is represented by #subform.
The reference syntax notation structure varies slightly, depending on the specific situation. For example, a fully qualified reference syntax
works in any situation; however, in some cases, you can use a shortened reference syntax or a reference syntax shortcut to reduce the size of
the syntax.
For example, this illustration shows the hierarchy of a sample purchase order form.
This illustration shows a fully qualified reference syntax, for both FormCalc and JavaScript, to access the value of the txtCondition field.
This reference syntax could be used as part of a calculation or script on any object on the form.
A. Root Node B. Model C. Form design root node D. Page object E. Subform name F. Object name G. Property or method name
Note: Even though the reference syntax is common to both FormCalc and JavaScript, you must observe the conventions for each scripting
language. For example, the reference syntax in the example above works as is for FormCalc; however, you would need to include a trailing
semicolon (;) character for JavaScript.
If two objects exist in the same container, such as a subform, they are referred to as sharing the same context. Where objects exist in the same
context, you can use an abbreviated reference syntax that includes only the name of the object followed by the property or method you want
to access. For example, using the example from above, the following abbreviated reference syntax accesses the value of the txtCondition
field from any of the fields in the total subform:
txtCondition.rawValue
If two objects exist in different containers, they do not share the same context. In this case, you can use an abbreviated reference syntax;
however, the syntax must begin with the name of the highest level container object that the two objects do not have in common. For example,
using the hierarchy above, the following abbreviated reference syntax accesses the value of the address field from the txtCondition field:
LIVECYCLE DESIGNER ES2 60
Referencing Objects in Calculations and Scripts LiveCycle Designer ES2 Scripting Basics
header.address.rawValue
Due to the way the XML Form Object Model is structured, some object properties and methods exist on child objects of the objects on the
form. These child objects exist only as part of the XML Form Object Model and do not appear in the Hierarchy and Data View palettes. To
access these properties and methods, you must include the child objects in the reference syntax. For example, the following reference syntax
sets the tool tip text for the txtCondition field:
txtCondition.assist.toolTip.value = "Conditions of purchase." // FormCalc
txtCondition.assist.toolTip.value = "Conditions of purchase."; // JavaScript
For more information about the XML Form Object model objects and their structure, see Designer ES2 Scripting Reference.
The untitled subform that represents the first page of the form has an occurrence number of 0. In this situation, both of the following
reference syntaxes access the value of the text field in the form hierarchy above on a new form that uses default naming conditions:
xfa.form.form1.#subform.TextField1.rawValue
xfa.form.form1.#subform[0].TextField1.rawValue
Note: By default, if you do not specify an occurrence value for an object, the reference syntax accesses the first occurrence of that object.
FormCalc recognizes the fully qualified reference syntax above and interprets it directly. To access the same value by using JavaScript, you
must use one of these forms of the resolveNode scripting method:
xfa.resolveNode("xfa.form.form1.#subform.TextField1").rawValue;
xfa.resolveNode("xfa.form.form1.#subform[0].TextField1").rawValue;
If you add a new page to your form, by default, the name of the subform that represents the new page is unnamed; however, the occurrence
value for the new subform is set to 1. You can specify the new unnamed subform by using a similar reference syntax as above:
LIVECYCLE DESIGNER ES2 61
Referencing Objects in Calculations and Scripts LiveCycle Designer ES2 Scripting Basics
xfa.form.form1.#subform[1].TextField1.rawValue // FormCalc
xfa.resolveNode("xfa.form.form1.#subform[1].TextField1").rawValue; // JavaScript
Note: The statement completion options available in the Script Editor include unnamed objects at the beginning of the list. Objects that have
multiple occurrence values appear only once in the list, representing the first occurrence of the object. If you want to access an occurrence value
other that the first occurrence, you must manually add the occurrence value to the reference syntax.
You can use the resolveNode method to reference objects within other reference syntax statements. This can help to reduce the amount of
scripting you need to reference a particular object, property, or method. For example, you could simplify the reference syntax that points to
a text field on the second page of your form to the following statement:
xfa.form.form1.resolveNode("#subform[1].TextField1").rawValue; // JavaScript
Similarly, you can use the dollar sign ($) shortcut and the keyword this to replace the name of the current object when accessing object
properties in calculations and scripts. For example, the following reference syntax changes the tool tip text associated with the current object:
$.assist.toolTip.value = "This is some tool tip text." // FormCalc
this.assist.toolTip.value = "This is some tool tip text."; // JavaScript
Notation Description
$ = "Tony Blue"
The above example sets the value of the current field or object to Tony Blue.
$data Represents the root of the data model xfa.datasets.data. For example,
$data.purchaseOrder.total
is equivalent to
xfa.datasets.data.purchaseOrder.total
$event.name
is equivalent to
xfa.event.name
$form Represents the root of the form model xfa.form. For example,
$form.purchaseOrder.tax
is equivalent to stating
xfa.form.purchaseOrder.tax
LIVECYCLE DESIGNER ES2 62
Referencing Objects in Calculations and Scripts LiveCycle Designer ES2 Scripting Basics
Notation Description
$host.messageBox("Hello world")
is equivalent to
xfa.host.messageBox("Hello world")
$layout Represents the root of the layout model xfa.layout. For example,
$layout.ready
is equivalent to stating
xfa.layout.ready
$record Represents the current record of a collection of data, such as from an XML file. For example,
$record.header.txtOrderedByCity
references the txtOrderedByCity node within the header node of the current XML data.
$template Represents the root of the template model xfa.template. For example,
$template.purchaseOrder.item
is equivalent to
xfa.template.purchaseOrder.item
!data
is equivalent to
xfa.datasets.data
* Selects all form objects within a given container, such as a subform, regardless of name, or selects all objects that have
a similar name.
For example, the following expression selects all objects named item on a form:
xfa.form.form1.item[*]
You can use the ‘*’ (asterisk) syntax with JavaScript if it used with the resolveNode method. For more information
about the resolveNode method, see Designer ES22 Help, or see LiveCycle Designer ES2 Scripting Reference.
LIVECYCLE DESIGNER ES2 63
Referencing Objects in Calculations and Scripts LiveCycle Designer ES2 Scripting Basics
Notation Description
.. You can use two dots at any point in your reference syntax to search for objects that are a part of any subcontainer of
the current container object, such as a subform. For example, the expression Subform_Page..Subform2 means
locate the node Subform_Page (as usual) and find a descendant of Subform_Page called Subform2.
Subform_Page..TextField2
is equivalent to
Subform_Page.Subform1[0].Subform3.TextField2[0]
because TextField2[0] is in the first Subform1 node that FormCalc encounters on its search. As a second
example,
Subform_Page..Subform3[*]
You can use the ‘..’ (double period) syntax with JavaScript if it used with the resolveNode method. For more informa-
tion about the resolveNode method, see Designer ES22 Help, or see LiveCycle Designer ES2 Scripting Reference.
# The number sign (#) notation is used to denote one of the following items in a reference syntax:
• An unnamed object. For example, the following reference syntax accesses an unnamed subform:
xfa.form.form1.#subform
• Specify a property in a reference syntax if a property and an object have the same name. For example, the following
reference syntax accesses the name property of a subform if the subform also contains a field named name:
xfa.form.form1.#subform.#name
You can use the ‘#’ (number sign) syntax with JavaScript if it used with the resolveNode method. For more information
about the resolveNode method, see Designer ES22 Help, or see LiveCycle Designer ES2 Scripting Reference.
LIVECYCLE DESIGNER ES2 64
Referencing Objects in Calculations and Scripts LiveCycle Designer ES2 Scripting Basics
Notation Description
[ ] The square bracket ([ ]) notation denotes the occurrence value of an object. To construct an occurrence value refer-
ence, place square brackets ([ ]) after an object name, and enclose within the brackets one of the following values:
• [ n ], where n is an absolute occurrence index number beginning at 0. An occurrence number that is out of
range does not return a value. For example,
xfa.form.form1.#subform.Quantity[3]
refers to the fourth occurrence of the Quantity object.
• [ +/- n ], where n indicates an occurrence relative to the occurrence of the object making the reference. Positive
values yield higher occurrence numbers, and negative values yield lower occurrence numbers. For example,
xfa.form.form1.#subform.Quantity[+2]
This reference yields the occurrence of Quantity whose occurrence number is two more than
the occurrence number of the container making the reference. For example, if this
reference was attached to the Quantity[2]object , the reference would be the same as
xfa.template.Quantity[4]
If the computed index number is out of range, the reference returns an error.
The most common use of this syntax is for locating the previous or next occurrence of a
particular object. For example, every occurrence of the Quantity object (except the first)
might use Quantity[-1] to get the value of the previous Quantity object.
• [*] indicates multiple occurrences of an object. The first named object is found, and objects of the same name
that are siblings to the first are returned. Note that using this notation returns a collection of objects. For example,
xfa.form.form1.#subform.Quantity[*]
• This expression refers to all objects with a name of Quantity that are siblings to the first occurrence of
Quantity found by the reference.
In language-specific forms for Arabic, Hebrew, Thai, and Vietnamese, the reference syntax is always on the right (even
for right-to-left languages).
LIVECYCLE DESIGNER ES2 65
Referencing Objects in Calculations and Scripts LiveCycle Designer ES2 Scripting Basics
Notation Description
[ ]
(Continued)
Using the tree for reference, these expressions return the following objects:
You can use the ‘[ ]’ (square bracket) syntax with JavaScript if it used with the resolveNode method. For more infor-
mation about the resolveNode method, see Designer ES22 Help, or see LiveCycle Designer ES2 Scripting Reference.
66
A. Form level object B. Subform level object C. Subform level script object D. Form level script object
Example
For example, create a script object called feedback that contains the following function:
function emptyCheck(oField) {
Example
For example, using the script object example from “To add script to a script object” on page 66, place the following JavaScript script on the
exit event for a text field. Test the form using the Preview PDF tab.
feedback.emptyCheck(this)
68
Source File
Sets the source file for the fragment reference. This property is visible only when the selected object is a fragment reference.
Fragment Name
Sets the name of the fragment. You can click the Frag Info button to view the fragment information.
This property is visible when a fragment reference or a fragment that is defined in a source file is selected. When the selected object is a
fragment reference, this property does not appear if the source file is not specified. The Fragment Name list includes all the fragments in the
specified source file. The Custom option directly supports setting a SOM expression or an ID value as the fragment reference and supports
the implementation in the XML Forms Architecture.
FormCalc
xfa.host.messageBox(Concat("The value of NumericField1 is: ",
NumericField1), "Debugging", 3)
JavaScript
xfa.host.messageBox("The value of NumericField1 is: " +
NumericField1.rawValue, "Debugging", 3);
Caution: The messageBox method returns an integer value representing the button that the form filler selects in the message box dialog. If you
attach the messageBox method to the calculate event of a field object, and the messagebox method is the last line of the script, the field
displays the return value of the messageBox method at runtime.
JavaScript Debugging
If you use the JavaScript language for a script, you can use the console.println("string") function to output information to the JavaS-
cript Console available in Acrobat Professional. Alternatively, yu can use the alert method from the Acrobat JavaScript Object Model to
debug JavaScript.
For more information about the console.println method and the JavaScript Object Model from Acrobat, see Developing Acrobat Appli-
cations Using JavaScript (English only).
For more information about the JavaScript Console and the JavaScript Debugger, see Developing Acrobat Applications Using JavaScript
(English only).
For more information about the alert method and the JavaScript Object Model from Acrobat, see Developing Acrobat Applications Using
JavaScript (English only).
Debugging tips
Remember the following tips when debugging calculations and scripts.
Sample data
Remember to specify a preview data file in the Form Properties dialog box. Specifying a preview data file does not save the data into the
final PDF.
LIVECYCLE DESIGNER ES2 73
Debugging Calculations and Scripts LiveCycle Designer ES2 Scripting Basics
Master pages
To debug master pages, drop a different object on each master page to find out which one is specified.
Incremental debugging
When debugging a form design, start by removing pieces of the form until you cannot reproduce the problem. Try to isolate the source of
the problem after you've reviewed every script and object property. To debug subforms, you can specify a thick colored border around the
subform, or use a fill. Colors or fill can help indicate which subform is used and its span. Usually, this technique works well when you want
to determine the bounds of an object and can show why it is placed in a certain location.
Hierarchy view
View your form design by using the Hierarchy view to get a better understand of it. The order of the objects that are listed in the hierarchy
indicates the order they are placed on the page. Some objects are not clickable if they are below one another.
The problem is that an endif token is missing from the script. The last correct token is then (comments do not count as tokens). Adding
an endif statement to the end of the script fixes the problem.
Properties Methods
appType beep
calculationsEnabled exportData
currentPage gotoURL
language importData
name messageBox
numPages pageDown
platform pageUp
title print
validationsEnabled resetData
variation response
version setFocus
For more information about the host scripting model properties and methods, see the LiveCycle ES2 Developer Center located at
www.adobe.com/devnet/livecycle/.
Host scripting model properties and methods JavaScript Object Model from Acrobat equivalent
xfa.host.appType app.viewerType
xfa.host.currentPage doc.pageNum
Host scripting model properties and methods JavaScript Object Model from Acrobat equivalent
or
app.launchURL(URL);
xfa.host.language app.language
xfa.host.name none
xfa.host.numPages doc.numPages
xfa.host.pageDown() doc.pageNum++
xfa.host.pageUp() doc.pageNum--
xfa.host.platform app.platform
(Deprecated)
xfa.host.title doc.title
xfa.host.variation app.viewerVariation
xfa.host.version app.viewerVersion
77
Properties Methods
change emit
className reset
commitKey
fullText
keyDown
modifier
name
newContentType
newText
prevContentType
prevText
reenter
selEnd
selStart
shift
soapFaultCode
soapFaultString
target
For more information about the event scripting model properties and methods, see the Adobe Designer ES2 Developer Center located at
www.adobe.com/devnet/livecycle/designing_forms.html.
78
You can also have the form send itself by email by adding the following script to the click event of a button:
var myDoc = event.target;
myDoc.mailDoc(true);
Note: In Designer ES2, you must ensure that the scripting language for the event is set to JavaScript so that the script will execute correctly at
run time.
You can also use references to the JavaScript objects in Acrobat in your reference syntax. For example, the following script gets the signed
state of a signature field and takes an action based on the state:
// Proceed if the current field is not signed.
var oState =
event.target.getField("form1[0].#subform[0].SignatureField1[0]")
.signatureValidate(); //Get the field's signed state.
if (oState == 0) {
...
}
Note: This example uses a fully qualified reference syntax to reference the text For more information about referencing form design objects, see
“Referencing object properties and values” on page 58.
When working with JavaScript from Acrobat in Designer ES2, remember these points:
• In Designer ES2, use event.target to access the Doc JavaScript object from Acrobat. In Acrobat, the this object is used to reference
the Doc object; however, in Designer ES2, the this object refers to the form design object to which the script is attached.
• The Script Editor has no statement completion for JavaScript objects from Acrobat. See the JavaScript for Acrobat API Reference.
• The Doc method event.target.importTextData("file.txt") is not supported for dynamic XFA forms that have been certified.
For more information about converting Acrobat scripting to Designer ES2, see the article Converting Acrobat JavaScript for Use in
Designer ES2 Forms in the LiveCycle ES2 Developer Center.
All properties and methods Yes None Only forms with a fixed layout support
the annotation layer.
newFDF No None
openFDF No None
calculate No None
delay No None
var sOrigXML =
xfa.data.saveXML;
if (sOrigXML !=
xfa.data.saveXML)
{...}
xfa.host.pageUp()
xfa.host.pageDown()
addLink No None
addThumbnails No None
extractPages No None
getLinks No None
getNthFieldName Yes You must loop through all objects with See the className property.
a similar class name until you reach the
nth occurrence.
getNthTemplate No None
getTemplate No None
gotoNamedDest No None
importAnFDF No None
insertPages No None
mailForm No None
movePage No None
newPage No None
removeField No None
removeLinks No None
removeTemplate No None
removeThumbnails No None
replacePages No None
app.executeMenuItem
("SaveAs");
or
spawnPageFromTemplate No None
setAction No None
setPageRotation No None
setScript No None
comb No None
display = display.noView No See “Changing the presence of a form You can also set the presence prop-
design object” on page 106. erty in the Designer ES2 workspace.
display = display.noPrint No See “Changing the presence of a form You can also set the presence prop-
design object” on page 106. erty in the Designer ES2 workspace.
hidden No this.presence = "invisible" You can also set the presence prop-
this. erty in the Designer ES2 workspace.
presence = "visible"
rect Yes You can get the height and width of a See the h, w, x, and y properties.
Designer ES2 form field by using the
following reference syntax:
this.h;
this.w;
this.x;
this.y;
this.validate.nullTest =
"error";
deleteItemAt No None
getItemAt No None
isDefaultChecked No None
setItems No None
In this example, clicking a button changes the background color of an associated object.
Note: To manipulate the background color of objects at run time, you must save your form as an Acrobat Dynamic XML Form file.
To see this scripting example and others, visit the LiveCycle ES2 Developer Center at www.adobe.com/devnet/livecycle.
The following lines make up the script for the background color of the text fields:
Subform1.Name.fillColor = "102,179,255";
Subform1.Address.fillColor = "102,179,255";
Subform1.City.fillColor = "102,179,255";
Subform1.State.fillColor = "102,179,255";
Subform1.ZipCode.fillColor = "102,179,255";
Subform1.Country.fillColor = "102,179,255";
The form filler can use the drop-down lists in the Presence Values area to show or hide objects. In the following diagram, the Address field
is hidden and the form layout has adjusted accordingly. The Print Form button is also invisible.
Note: To hide and show objects at run time, you must save your form as an Acrobat Dynamic PDF Form file.
To see this scripting example and others, visit the LiveCycle ES2 Developer Center www.adobe.com/devnet/livecycle.
The second variable stores the name of the text field that the form filler selects in the Text Fields drop-down list:
var sSelectField = fieldList.rawValue;
The following script uses the replace method to remove all of the spaces from the name of the field stored in the sSelectField variable,
which allows the value of the drop-down list to match the name of the object in the Hierarchy palette:
sSelectField = sSelectField.replace(' ', '');
This script uses a For loop to cycle through all of the objects contained in Subform1:
for (var nCount = 0; nCount < nSubLength; nCount++) {
If the current object in Subform1 is of type field and the current object has the same name as the object that the form filler selected, the
following switch cases are performed:
if ((Subform1.nodes.item(nCount).className == "field") & (Subform1.nodes.item(nCount).name == sSelectField)) {
The following script uses a switch statement to handle the three presence values that a form filler can apply to text field objects:
switch(xfa.event.newText) {
case 'Invisible':
Subform1.nodes.item(nCount).presence = "invisible";
break;
case 'Hidden (Exclude from Layout)':
Subform1.nodes.item(nCount).presence = "hidden";
break;
default:
Subform1.nodes.item(nCount).presence = "visible";
break;
}
}
}
This variable stores the name of the button that the form filler selects in the Buttons drop-down list:
var sSelectButton = buttonList.rawValue;
The following script uses the replace method to remove all of the spaces from the name of the button stored in the sSelectField variable,
which allows the value of the drop-down list to match the name of the object in the Hierarchy palette:
sSelectButton = sSelecButton.replace(/\s/g, '');
This script uses a For loop to cycle through all of the objects contained in Subform1:
for (var nCount = 0; nCount < nSubLength; nCount++) {
If the current object in Subform1 is of type field and the current object has the same name as the object that the form filler selected,
perform the following switch cases:
if ((Subform1.nodes.item(nCount).className == "field") &
Subform1.nodes.item(nCount).name == sSelectButton)) {
This script uses a switch statement to handle the five presence values that a form filler can apply to button objects.
Note: The relevant property indicates whether an object should appear when the form is printed.
switch(xfa.event.newText) {
case 'Invisible':
Subform1.nodes.item(nCount).presence = "invisible";
LIVECYCLE DESIGNER ES2 94
Examples of Common Scripting Tasks LiveCycle Designer ES2 Scripting Basics
break;
case 'Hidden (Exclude from Layout)':
Subform1.nodes.item(nCount).presence = "hidden";
break;
case 'Visible (but Don\'t Print)':
Subform1.nodes.item(nCount).presence = "visible";
Subform1.nodes.item(nCount).relevant = "-print";
break;
case 'Invisible (but Print Anyway)':
Subform1.nodes.item(nCount).presence = "invisible";
Subform1.nodes.item(nCount).relevant = "+print";
break;
default:
Subform1.nodes.item(nCount).presence = "visible";
break;
}
}
}
Use the remerge method to remerge the form design and form data. In this case, the method effectively returns the objects in the Form
Objects area to their original states:
xfa.form.remerge();
In this case, by default, the user’s experience would be to move sequentially in the following order:
To exclude DropDownList1 from the tabbing sequence, you would add the following scripts to the TextField2 object:
Event Script
Note: To alter the visual properties of objects on the client, you must save your form as an Acrobat Dynamic PDF Form file.
In this example, the check boxes do not have unique object names; therefore, Designer ES2 assigns an instance value to reference the object.
The check box script uses an if-else statement to give the effect of selecting and deselecting.
To see this scripting example and others, visit the LiveCycle ES2 Developer Center www.adobe.com/devnet/livecycle.
Scripting for the Change the Border Color of the Object check box
When the check box is selected, the field border changes to red. When the check box deselected, the field border changes to white.
if (CheckBox4.rawValue == true)
TextField.border.edge.color.value = "255,0,0";
else
TextField.border.edge.color.value = "255,255,255";
Scripting for the Change the Fill Color of the Fillable Area check box
When the check box is selected, the fillable area of the text field changes to green. When the check box is deselected, the fillable area of the
text field changes to white.
if (CheckBox5.rawValue == true) {
xfa.resolveNode("TextField.ui.#textEdit.border.fill.color").value = "0,255,0";
}
else {
xfa.resolveNode("TextField.ui.#textEdit.border.fill.color").value = "255,255,255";
}
Scripting for the Expand to Fit the Width of the Value check box
When the check box is selected, the fillable area of the text field adjusts to accommodate the value. When the check box is deselected, the
fillable area of the text field does not adjust.
if (CheckBox6.rawValue == true)
TextField.minW = "0.25in";
else
TextField.maxW = "2.5in";
Scripting for the Change the Font of the Value check box
When the check box is selected, the font of the value changes to Courier New. When the check box is deselected, the font of the value changes
to Myriad Pro.
if (CheckBox8.rawValue == true)
LIVECYCLE DESIGNER ES2 98
Examples of Common Scripting Tasks LiveCycle Designer ES2 Scripting Basics
Scripting for the Change the Size of the Font check box
When the check box is selected, the font size changes to 14 pt. When the check box is deselected, the font size changes to 10 pt.
if (CheckBox9.rawValue == true)
TextField.font.size = "14pt";
else
TextField.font.size = "10pt";
Scripting for the Align Text Field Value Vertically check box
When the check box is selected, the text field value is aligned to the top. When the check box is deselected, the text field value is aligned to
the middle.
if (CheckBox10.rawValue == true)
TextField.para.vAlign = "top";
else
TextField.para.vAlign = "middle";
Scripting for the Align Text Field Value Horizontally check box
When the check box is selected, the text field value is aligned to the center. When the check box is deselected, the text field value is aligned
to the left.
if (CheckBox11.rawValue == true)
TextField.para.hAlign = "center";
else
TextField.para.hAlign = "left";
Scripting for the Change Field Border from 3D to Solid check box
When the check box is selected, the field border changes to a solid box. When the check box is deselected, the field border changes to 3D.
if (CheckBox14.rawValue == true)
xfa.resolveNode("TextField.ui.#textEdit.border.edge").stroke = "solid";
else
xfa.resolveNode("TextField.ui.#textEdit.border.edge").stroke = "lowered";
LIVECYCLE DESIGNER ES2 99
Examples of Common Scripting Tasks LiveCycle Designer ES2 Scripting Basics
Use the remerge method to remerge the form design and form data. In this case, the method effectively returns the text field to its original
state.
xfa.form.remerge();
Note: Each of the methods for obtaining the previous value of a drop-down list uses a different script. The Previous Value 1 text field is populated
by a direct reference to the rawValue property of the drop-down list, whereas the Previous Value 2 text field is populated using the prevText
property. For consistent results, it is recommended that you access the previous value by using the prevText property.
To see this scripting example and others, visit the LiveCycle ES2 Developer Center at www.adobe.com/devnet/livecycle.
TextField1 and TextField2 are configured to Allow Multiple Lines and display rich text formatting.
The Copy Rich Text button copies the value of TextField1, including rich text formatting, and pastes it in TextField2.
In this example, the rich text value is set to overwrite the existing value of TextField2. Adjusting the script to the following would append
the rich text data to the current value of TextField2:
var richText = TextField1.value.exData.saveXML();
TextField2.value.exData.loadXML(richText,1,0);
To see this scripting example and others, visit the LiveCycle ES2 Developer Center at www.adobe.com/devnet/livecycle.
To see this scripting example and others, visit the LiveCycle ES2 Developer Center www.adobe.com/devnet/livecycle.
To see this scripting example and others, visit the LiveCycle ES2 Developer Center at www.adobe.com/devnet/livecycle.
LIVECYCLE DESIGNER ES2 102
Examples of Common Scripting Tasks LiveCycle Designer ES2 Scripting Basics
var total = 0;
for (var i=0; i <= fields.length-1; i++) {
total = total + fields.item(i).rawValue;
}
this.rawValue = total;
var total = 0;
for (var i=0; i <= fields.length-1; i++) {
total = total + fields.item(i).rawValue;
}
this.rawValue = total;
var total = 0;
for (var i=0; i <= fields.length-1; i++) {
if (fields.item(i).name == "NumericField1") {
total = total + fields.item(i).rawValue;
}
}
this.rawValue = total;
In this example, an asterisk (*) appears to the right of the required fields. When a field is selected, the field border changes to blue. If the
form filler clicks the Verify Data button without having filled the required fields, a message appears and the field changes to red. If all the
required fields are filled, a confirmation message appears when the form filler clicks the Verify Data button.
To see this scripting example and others, visit the LiveCycle ES2 Developer Center at www.adobe.com/devnet/livecycle.
var iVar = 0;
This script changes the color of the fillable area of the text field:
xfa.resolveNode("Name.ui.#textEdit.border.edge").stroke = "solid";
xfa.resolveNode("Name.ui.#textEdit.border.fill.color").value = "255,100,50";
// Set the variable to indicate that this field does not contain data.
iVar = 1;
}
else {
// Reset the fillable area of the text field.
xfa.resolveNode("Name.ui.#textEdit.border.edge").stroke = "lowered";
xfa.resolveNode("Name.ui.#textEdit.border.fill.color").value = "255,255,255";
}
This script changes the color of the fillable area of the text field:
xfa.resolveNode("Address.ui.#textEdit.border.edge").stroke = "solid";
xfa.resolveNode("Address.ui.#textEdit.border.fill.color").value = "255,100,50";
This script sets the variable to indicate that this field does not contain data:
iVar = 1;
}
else {
This script changes the color of the fillable area of the text field:
xfa.resolveNode("City.ui.#textEdit.border.edge").stroke = "solid";
xfa.resolveNode("City.ui.#textEdit.border.fill.color").value = "255,100,50";
This script sets the variable to indicate that this field does not contain data:
iVar = 1;
}
else {
This script changes the color of the fillable area of the text field:
xfa.resolveNode("State.ui.#textEdit.border.edge").stroke = "solid";
LIVECYCLE DESIGNER ES2 105
Examples of Common Scripting Tasks LiveCycle Designer ES2 Scripting Basics
xfa.resolveNode("State.ui.#textEdit.border.fill.color").value = "255,100,50";
This script sets the variable to indicate that this field does not contain data:
iVar = 1;
}
else {
This script changes the color of the fillable area of the text field:
xfa.resolveNode("ZipCode.ui.#textEdit.border.edge").stroke = "solid";
xfa.resolveNode("ZipCode.ui.#textEdit.border.fill.color").value = "255,100,50";
This script sets the variable to indicate that this field does not contain data:
iVar = 1;
}
else {
This script changes the color of the fillable area of the text field:
xfa.resolveNode("Country.ui.#textEdit.border.edge").stroke = "solid";
xfa.resolveNode("Country.ui.#textEdit.border.fill.color").value = "255,100,50";
This script sets the variable to indicate that this field does not contain data.
iVar = 1;
}
else {
If all of the required fields contain data, the iVar variable is set to zero, and a confirmation message appears:
if (iVar == 0) {
xfa.host.messageBox("Thank you for inputting your information.");
}
In this example, the form filler can click the Clear button to reset the field values.
To see this scripting example and others, visit the LiveCycle ES2 Developer Center www.adobe.com/devnet/livecycle.
To reset the default values add a click event to the Clear button. You need a dynamic reference syntax expression because the detail is a
repeating subform and must be reflected in the reference syntax expression. In this situation, it is easier to build the resetData parameters
separately.
var f1 = this.parent.somExpression + ".TextField2" + ",";
var f2 = f1 + this.parent.somExpression + ".DropDownList1" + ",";
var f3 = f2 + this.parent.somExpression + ".NumericField1";
Visible FormCalc
ObjectName.presence = "visible"
JavaScript
ObjectName.presence = "visible";
ObjectName.presence = "visible"
ObjectName.relevant = "-print"
JavaScript
ObjectName.presence = "visible";
ObjectName.relevant = "-print";
LIVECYCLE DESIGNER ES2 107
Examples of Common Scripting Tasks LiveCycle Designer ES2 Scripting Basics
ObjectName.presence = "visible"
ObjectName.relevant = "+print"
JavaScript
ObjectName.presence = "visible";
ObjectName.relevant = "+print";
Invisible FormCalc
ObjectName.presence = "invisible"
JavaScript
ObjectName.presence = "invisible";
ObjectName.presence = "hidden"
JavaScript
ObjectName.presence = "hidden";
ObjectName.presence = "simplex"
JavaScript
ObjectName.presence = "simplex";
ObjectName.presence = "duplex"
JavaScript
ObjectName.presence = "duplex";
In the following form, the four buttons provide information about Subform1 by using the instance manger’s scripting properties. For
example, when the form filler clicks the Max button, a message describing the allowed maximum number of supported Subform1 instances
appears.
Scripting for the message box to output the value of the count property
The following script uses the messageBox method to output the value of the count property:
xfa.host.messageBox("The current number of Subform1 instances on the
form is:" + properties.Subform1.instanceManager.count, "Instance Manager
Properties",3);
You can also write this script by using the underscore (_) notation to reference the count property of the instance manager, as shown here:
xfa.host.messageBox("The current number of Subform1 instances on the form
is: " + properties._Subform1.count, "Instance Manager Properties", 3);
The underscore (_) notation is especially important if no subform instances currently exist on the form.
Scripting for the message box to output the value of the max property
The following script uses the messageBox method to output the value of the max property:
xfa.host.messageBox("The maximum number of instances allowed for Subform1
is: " + properties.Subform1.instanceManager.max, "Instance Manager
Properties", 3);
You can also write this script by using the underscore (_) notation to reference the max property of the instance manager, as shown here:
xfa.host.messageBox("The maximum number of instances allowed for Subform1
is: " + properties._Subform1.max, "Instance Manager Properties", 3);
Scripting for the message box to output the value of the min property
The following script uses the messageBox method to output the value of the min property:
xfa.host.messageBox("The minimum number of instances allowed for Subform1
is: " + properties.Subform1.instanceManager.min, "Instance Manager
Properties", 3);
You can also write this script by using the underscore (_) notation to reference the min property of the instance manager, as shown here:
LIVECYCLE DESIGNER ES2 109
Examples of Common Scripting Tasks LiveCycle Designer ES2 Scripting Basics
Scripting for the message box to output the name of the subform property
The following script uses the messageBox method to output the name of the subform property:
xfa.host.messageBox("The name of the subform using the instance manager name
property is: " + properties.Subform1.instanceManager.name +
".\n\nNote: This value is different than the value returned by the name
property for the Subform1 object." , "Instance Manager Properties", 3);
You can also write this script by using the underscore (_) notation to reference the name property of the instance manager, as shown here:
xfa.host.messageBox("The name of the subform using the instance manager name
property is: " + properties._Subform1.name +
".\n\nNote: This value is different than the value returned by the name
property for the Subform1 object." , "Instance Manager Properties", 3);
Note: The Move button reorders the first two Subform2 instances, and the Set button displays the maximum number of Subform2 instances. In
both cases, you may need to add or remove subforms, or make changes to the data in the text fields to see the changes applied to the Subform2
instances.
Scripting to determine whether you added the maximum number of subforms to a form
The following script determines whether the supported maximum number of Subform2 instances exist on the form. If the maximum
number exists, the script displays a message. Otherwise, a new Subform2 instance is added to the form.
if (methods.Subform2.instanceManager.count ==
methods.Subform2.instanceManager.max) {
xfa.host.messageBox("You have reached the maximum number of items allowed.",
"Instance Manager Methods", 1);
}
else {
methods.Subform2.instanceManager.addInstance(1);
xfa.form.recalculate(1);
LIVECYCLE DESIGNER ES2 110
Examples of Common Scripting Tasks LiveCycle Designer ES2 Scripting Basics
}
You can also write this script by using the underscore (_) notation to reference the properties and methods of the instance manager, as shown
here:
if (methods._Subform2.count == methods._Subform1.max) {
xfa.host.messageBox("You have reached the maximum number of items
allowed.", "Instance Manager Methods", 1);
}
else {
methods._Subform2.addInstance(1);
xfa.form.recalculate(1);
}
Scripting to determine whether there are more subforms to remove on the form
The following script determines whether any Subform2 instances exist on the form. If none exist, the script displays a message indicating
that no instances exist. If instances do exist, the script removes the first instance from the form.
if (methods.Subform2.instanceManager.count == 0) {
xfa.host.messageBox("There are no subform instances to remove.",
"Instance Manager Methods", 1);
}
else {
methods.Subform2.instanceManager.removeInstance(0);
xfa.form.recalculate(1);
}
You can also write this script by using the underscore (_) notation to reference the properties and methods of the instance manager, as shown
here:
if (methods._Subform2.count == 0) {
xfa.host.messageBox("There are no subform instances to remove.",
"Instance Manager Methods", 1);
}
else {
methods._Subform2.removeInstance(0);
xfa.form.recalculate(1);
}
You can also write this script by using the underscore (_) notation to reference the properties and methods of the instance manager, as shown
here:
methods._Subform2.setInstances(4);
Scripting to force the first and second subforms to switch locations on the form
The following script forces the first and second Subform2 instances to switch locations on the form.
methods.Subform2.instanceManager.moveInstance(0,1);
You can also write this script by using the underscore (_) notation to reference the properties and methods of the instance manager, as shown
here.
methods._Subform2.moveInstance(0,1);
LIVECYCLE DESIGNER ES2 111
Examples of Common Scripting Tasks LiveCycle Designer ES2 Scripting Basics
Note: If no instances of a particular subform exist on your form, you must use the underscore (_) notation provided with each example below.
For more information about using the underscore (_) notation, see Designer ES2 Help.
You can also write this script by using the underscore (_) notation to reference the properties and methods of the instance manager, as shown
here:
if (advanced._Subform3.count == advanced._Subform3.max) {
xfa.host.messageBox("You have reached the maximum number of items
allowed.", "Combining Instance Manager Concepts", 1);
}
else {
advanced._Subform3.addInstance(1);
xfa.form.recalculate(1);
}
LIVECYCLE DESIGNER ES2 112
Examples of Common Scripting Tasks LiveCycle Designer ES2 Scripting Basics
You can also write this script by using the underscore (_) notation to reference the properties and methods of the instance manager, as shown
here:
if (advanced._Subform3.count == 0) {
xfa.host.messageBox("There are no subform instances to remove.",
"Combining Instance Manager Concepts", 1);
}
else {
advanced._Subform3.removeInstance(0);
}
In this case, when the script references the value for nIndexFrom, the new instance of Subform3 is added to the form in the position specified
in the moveInstance method:
Subform3.instanceManager.moveInstance(nIndexFrom, nIndexTo);
}
else {
xfa.host.messageBox("You have reached the maximum number of items
allowed.", "Combining Instance Manager Concepts", 1);
}
You can also write this script by using the underscore (_) notation to reference the properties and methods of the instance manager, as shown
here:
if (_Subform3.count < _Subform3.occur.max) {
var oNewInstance = _Subform3.addInstance(1);
var nIndexFrom = oNewInstance.index;
var nIndexTo = Subform3.index + 1;
_Subform3.moveInstance(nIndexFrom, nIndexTo);
}
else {
xfa.host.messageBox("You have reached the maximum number of items allowed.", "Combining Instance Manager
Concepts", 1);
}
LIVECYCLE DESIGNER ES2 113
Examples of Common Scripting Tasks LiveCycle Designer ES2 Scripting Basics
You can also write this script by using the underscore (_) notation to reference the properties and methods of the instance manager, as shown
here:
if (_Subform3.count > _Subform3.occur.min) {
Subform3.removeInstance(Subform3.index);
}
else {
xfa.host.messageBox("You have reached the minimum number of items allowed.",
"Combining Instance Manager Concepts", 1);
}
You can also write this script by using the underscore (_) notation to reference the properties and methods of the instance manager, as shown
here:
if (Subform3.index != 0) {
var nIndexFrom = Subform3.index;
var nIndexTo = Subform3.index - 1;
Subform3.moveInstance(nIndexFrom, nIndexTo);
}
else {
xfa.host.messageBox("The current item can't be moved since it already is the first instance in the
list.", "Combining Instance Manager Concepts", 1);
}
The following if-else statement prevents the script from proceeding if the instance of Subform3 appears as the last instance in the list:
if ((nIndex + 1) < Subform3.instanceManager.count) {
// nIndexFrom and nIndexTo store the before and after index values to use with the moveInstance() method.
var nIndexFrom = nIndex;
var nIndexTo = nIndex + 1;
Subform3.instanceManager.moveInstance(nIndexFrom, nIndexTo);
}
else {
xfa.host.messageBox("The current item cannot be moved because it is the last
instance in the list.", "Combining Instance Manager Concepts", 1);
}
You can also write this script by using the underscore (_) notation to reference the properties and methods of the instance manager, as shown
here:
var nIndex = Subform3.index;
if ((nIndex + 1) < Subform3.instanceManager.count) {
var nIndexFrom = nIndex;
var nIndexTo = nIndex + 1;
_Subform3.moveInstance(nIndexFrom, nIndexTo);
}
else {
xfa.host.messageBox("The current item can't be moved since it already is the
last instance in the list.", "Combining Instance Manager Concepts", 1);
}
115
Index
A D postOpen (application event) 37
adding debugging postPrint (application event) 38
FormCalc functions to objects 47 about calculations and scripts 70 postSave (application event) 38
JavaScript scripts to objects 54 calculations and scripts 14, 22 postSign (application event) 39
script fragments 69 enabling the JavaScript Debugger 71 postSubmit (application event) 39
scripts to script objects 66 executing JavaScript scripts 71 preOpen (interactive event) 40
Adobe Acrobat using the messageBox method 70 prePrint (application event) 40
converting forms containing scripts 78 default preSave (application event) 41
JavaScript object model 78 processing application, setting 13 preSign (application event) 41
Adobe LiveCycle Designer ES scripting language, setting 13, 14 preSubmit (application event) 42
converting Acrobat forms to 78 defining text variables 55 processing events 24
scripting, moving from Acrobat 78 displaying scripting, viewing 20
application events 27 international characters 14 scripts associated with 20
Arabic characters, displaying 14 Script Editor 13 types of 24
array referencing 64 docClose event 30 validate (processing event) 42
docReady event 31 executing
B drop-down lists, value of, obtaining 99 events 24
basic calculations 48 scripts in JavaScript Console 71
built-in functions, FormCalc 47 E exit event 32
enter event 31 expressions, Acrobat-equivalent 75
C event model
calculate event 28 about 77 F
calculations scripting properties and methods 77 fields
about 9 event propagation 16 at run time, setting as required 101
about creating 16 events background color, changing 89
adding object reference syntax to 19 about 20, 24 height, adjusting at run time 100
attaching to objects 16 application events 27 highlighting 102
creating 17, 19 calculate (processing event) 28 sums, calculating 101
current object, referencing 61 change (interactive event) 29 form designs
debugging 14, 22, 70 click (interactive event) 30 object naming conventions 16
event model properties and methods 77 docClose (application event) 30 objects, changing presence of 106
referencing objects in 58, 60, 61 docReady (application event) 31 FormCalc
running 20, 21 enter (interactive event) 31 about 17, 47
testing 22 exit (interactive event) 32 basic calculations 48
variables 56 formready (processing event) 32 built-in functions 47
change event 29 full (interactive event) 33 function syntax 48
click event 30 indexChange (processing event) 33 functions 44
colors, background, changing 89 initialize (processing event) 34 functions, adding to objects 47
comparing FormCalc and JavaScript 44 interactive 25 reference syntax shortcuts 61
creating layoutready (processing event) 34 referencing objects 58, 60, 61
calculations and scripts 17, 19 mouseDown (interactive event) 35 formready event 32
script fragments 68 mouseEnter (interactive event) 36 forms, converting from Acrobat to LiveCycle
script objects 66 mouseExit (interactive events 36 Designer ES 78
mouseUp (interactive event) 37 fragments. See script fragments 68
full event 33
INDEX 116
J P scripting properties
JavaScript postOpen event 37 Acrobat-equivalent 75
about 17, 50 postPrint event 38 host scripting model 75
to control subforms 107
scoping 51 postSave event 38
postSign event 39 scripts
adding scripts to objects 54
postSubmit event 39 about 9
enabling 71
preOpen event 40 about creating 16
functions 44
prePrint event 40 about debugging and testing 70
objects supported from Acrobat 79
preSave event 41 adding object reference syntax to 19
referencing objects 58, 60, 61
presence property 106 associating with events 20
using objects from Acrobat 78
preSign event 41 attached to objects, viewing 20
JavaScript Console
preSubmit event 42 attaching to objects 16
about 70
processing application, default 13 creating 17, 19
executing scripts in 71
processing events 24 current object, referencing 61
JavaScript Debugger
properties, visual, changing for objects 96 debugging 14, 22
about 70
executing in the JavaScript Console 71
enabling for LiveCycle Designer ES 71
R referencing objects in 58, 60, 61
prevent from disappearing 71
reference syntax running 20, 21
about 58 testing 22
L
adding to calculations and scripts 19 variables 56
layout
referencing object properties and values 58 sequence of events 24
eady event 34
referencing objects 60, 61 setting
shortcuts for FormCalc 61 default processing application 13
M
referencing script objects 67 default scripting language 13, 14
messageBox method 70
shortcuts, reference syntax 61
mouseDown event 35
S showing
mouseEnter event 36
Script Editor Script Editor 13
mouseExit event 36
about 11 scripting events and scripts 20
mouseUp event 37
displaying 13 showing objects 91
multiline view, Script Editor 11, 13
finding and replacing text in 18 simple expressions 48
INDEX 117
T
testing
calculations and scripts 22
JavaScript scripts 70
text variables
See also variables
defining 55
deleting 56
viewing definition 56
text, finding and replacing in XML Source tab and
Script Editor 18
Thai characters, displaying 14
triggering events 24
U
unnamed objects, referencing in calculations and
scripts 60
V
validate event 42
variables
See also text variables
about 55
in calculations and scripts 56
naming 55
naming conventions 16
Vietnamese characters, displaying 14
X
XML Form Object Model
about 58
instance manager 107
XML Source tab, finding and replacing text in 18