This function creates a persistent form variable. Persistent form variables can only be created in server-side form functions. Their scope sets whether they are available on the browser and whether or not they can be updated.
Executed
Server-side only. Variable names must be unique.
Arguments
Argument | Type | Description |
---|---|---|
name | String, required | Name of the variable to be set |
value | Any, required | The value of the variable. This can be of any type, including objects, arrays and the values of other fields/variables |
scope | String, optional | One of:
|
Scope
Helper variables can be set with a scope, which defines where they will be available to use. Persistent variables can only be created server-side.
Note than once a helper variable has been created it is not possible to change its scope. If no scope is specified the default is SERVERONLY.
helper.VARIABLE_SERVERONLY
The variable will be available to any functions executed server-side on any page of the form. Any changes made to its value in subsequent server-side functions will be saved.
The variable value is stored in the iCM database and will not appear browser-side, so it can be used to store more sensitive information if required. The value of the variable can be retrieved in the server-side functions of other fields.
helper.VARIABLE_SERVERCLIENT
The variable will be available to any functions executed server-side on any page of the form. Any changes made to its value in subsequent server-side functions will be saved.
It will also be available to any functions executed browser-side. Any changes made to the variable by browser-side functions will only be visible to the current page of the form. No changes made browser-side are submitted back to the server.
helper.VARIABLE_SERVERCLIENTUPDATE
The variable will be available to any functions executed server-side on any page of the form. Any changes made to its value in subsequent server-side functions will be saved.
It will also be available to any function executed browser-side. Any changes made to the variable by browser-side functions will be visible to the current page of the form and passed back to the server when the page data is successfully stored, making those changes available to subsequent pages.