Toggle menu

helper.createPersistentVariable(name, value [,scope])

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

ArgumentTypeDescription
nameString, requiredName of the variable to be set
valueAny, requiredThe value of the variable. This can be of any type, including objects, arrays and the values of other fields/variables
scopeString, optionalOne of:

helper.VARIABLE_SERVERONLY
helper.VARIABLE_SERVERCLIENT
helper.VARIABLE_SERVERCLIENTUPDATE

If no scope is set, helper.VARIABLE_SERVERONLY is assumed

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.

Last modified on March 20, 2024

Share this page

Facebook icon Twitter icon email icon

Print

print icon