Forms Scripting Scope of Variables
These tables cover the various places with the form model that scripting is allowed, and describe the default script variables that are in scope in those places.
The "f" array and "p" array functionality is deprecated. You can use control.<control-name>.getValue() instead of using "f" array and use p.get<parameter-name> instead of using the "p" array. See the table Action for details.
Variable | Description |
---|---|
context |
|
control |
Use control.<control-name> to access any control defined within the form. |
data |
Use data.get<param-name> to access the values of form parameters or data fields. This method returns either a primitive value for simple types such as Text and Boolean, or instances of objects when the type is defined in a BOM. For primitive types, data.set<param-name> is also available. |
factory |
Use factory.<package-name> to access factories based on packages defined within the business object models available to the form. These factories allow you to create new instances of classes defined in that package. |
pane |
Use pane.<pane-name> to access any pane defined within the form. |
pkg |
Use pkg.<package-name> to access package objects based on packages defined within the business object models available to the form. The package object allows you access definitions of Enumerations defined within the package. |
resource |
Use
resource.<external-resource-name>.<property-name> to access the localized values from property files. A property file can be added to the Presentation Resources folder and it can be referenced from a form by creating an External Resource in the form. For example: when a property file in the Presentation Resources folder is added as an External Resource in the form with the name
resource1, all the properties in that file can be accessed in a user-defined form action script from the object returned by
resource.resource1. Thus if the property file contains a property with name
name1, the value of this property can be retrieved in a user-defined script as:
resource.resource1.name1.
If a localized bundle is provided and a value exists for the property in that bundle, the value from that bundle is returned. If the property is missing in the localized bundle, the value from the base bundle is returned. Use resource.mappings.<parameter-name> to access the values in the data mappings file of the form. These keys represent the properties to which all the controls or panes in the form are bound. The Form Designer automatically generates the data mappings file in the Presentation Resources folder, and it can be referenced from a form as an External Resource. For more information, see Data Mappings File . |
f |
read-only. Field value array that accesses the current values of controls in the form. Field values can be accessed using
f.controlName. Field values can be updated by assigning a new value to them. Example:
f.foo=’newValue’;
Deprecated. Use control.cn.setValue(cv) instead of f.cn = cv; and var cv = control.cn.getValue(); instead of var cv = f.cn; |
p |
read-only. Parameter value array that accesses the inbound values of parameters.
p
can replace a pane and control. Parameter values can be accessed using
p.paramName.
Deprecated. Use data.setPn(pv); instead of p.pn = pv; and var pv = data.getPn(); instead of var pv = p.pn; |
this |
read-write. For actions that are initiated from a control event,
this refers to the control object from which the event is initiated. From
this, access the
form object and other controls and make updates to the state of the form model.
Deprecated. Use the new context variable that is available within the script. |
Validation
Variable | Description |
---|---|
f |
read-only. Field value array that accesses the current values of controls in the form. Field values can be accessed using
f.<control-name>.
Deprecated. Use var cv = control.cn.getValue(); instead of var cv = f.cn;. |
this |
read-only. Refers to the control object upon which the validation is configured. From
this, access the form object and other controls, although no updates to the form model are allowed within a form validation script.
Deprecated. Use context.value to get the value of the control being validated. |
context |
read-only. Within the scope of a validation script, the context variable supports only the following field:
context.value: This is equal to the value of the control being validated. If the control is multi-valued, such as a text control with the list setting enabled, then the validation is run once for each value in the list. |
resource |
User-defined validation scripts can retrieve localized values from property files using the resource variable. The resource details provided in the table Action are also applicable for validation scripts. |