Designer XFA Scripting Reference

 XF Scripting Reference


Adobe LiveCycle Designer is a software application used for creating forms and documents with dynamic and interactive content. It uses the XML Forms Architecture (XFA) standard to define form templates. XFA Scripting allows you to add interactivity, calculations, data validations, and other dynamic behaviors to your forms. Here are some basics of XFA Scripting in LiveCycle Designer:

Accessing Script Editor:

In LiveCycle Designer, go to menu bar and click on Window and select the option Script Editor

Supported Scripting Languages:

LiveCycle Designer supports JavaScript and FormCalc as scripting languages.
JavaScript is a versatile scripting language widely used for web development.
FormCalc is a scripting language designed specifically for form calculations and data manipulation.
Events and Scripts:

XFA Scripting is event-driven. Scripts are associated with specific events, such as field value change, button click, form initialization, etc.
When the event occurs, the associated script is executed.

Accessing Form Objects:
You can access form objects (fields, buttons, etc.) using their names, which can be seen in the Hierarchy palette.
Use the this keyword to refer to the current object (e.g., this.rawValue for the current field's value).

Basic Scripting Examples:

JavaScript:

// Example: JavaScript to calculate the sum of two fields and populate a third field.
var field1 = this.getField("Field1");
var field2 = this.getField("Field2");
var resultField = this.getField("ResultField");
resultField.rawValue = field1.rawValue + field2.rawValue;

FormCalc

' Example: FormCalc to calculate the VAT for a price field.
var price = PriceField.rawValue;
var vatRate = 0.20;  // Assuming 20% VAT rate
var vatAmount = price * vatRate;
VatField.rawValue = vatAmount;

Use the "Script Editor" to write, edit, and test your scripts.
The console can help you view errors and debug your scripts.

Global and Local Variables:

You can declare variables within scripts for storing data temporarily.
Global variables can be accessed across multiple scripts, while local variables are specific to the current script.

Conditional Statements and Loops:

You can use standard conditional statements (if-else) and loops (for, while) to control the flow of your scripts.

Binding:

XFA Scripting can also involve data binding, where form fields are bound to external data sources such as XML files or databases.
Remember that XFA Scripting in LiveCycle Designer provides a way to enhance the interactivity and functionality of your forms. The examples above provide a basic overview, but you can implement more complex behaviors using these scripting languages. Always refer to the LiveCycle Designer documentation and resources for more in-depth guidance and examples.

Reference scripts : 
1. Getting page no
var pageNo = xfa.layout.page(this);
2. Reading a XML node value from $record
xfa.resolveNode("$record.trackingCode")
3. Setting/getting a value from an object
this.rawValue = "abc";
QRCode_DocuSignIgnoreTransform.rawValue = "hello"
4. Get the page count
var pageCount = xfa.layout.pageCount()
5. Hiding the form object
this.presence="hidden";

Comments