Global Variables

Version II of Formworks has introduced the concept of Global Variables. Global Variables are variables that are entered in one form, and can then be retrieved by the same user from the device’s memory and used on subsequent forms. This data is set on a per-user / device basis. Global variables retain their value for 90 days from the point where they are set. Following this point, they must be re-saved to retain their values.

Two methods are employed to work with Global Variables - setUserData and getUserData. The format for their use is:

For example, to save the value from a text box with an alias of reference, into a Global Variable named Reference, the two methods would be coded as follows:
setUserData("Reference",reference.value);      -- Store the value of the reference element.
getUserData("Reference");                               -- Retrieve the value from “Reference”.


In this example, the OnSubmitAndConfirm event of a form is used to capture the value from a text element with an alias of reference, and store it in a global variable named Reference. You can then employ the OnOpen event of a different form to retrieve the value from the Global Variable Reference, and place it into the Value property of the second forms Reference field.



Was this article helpful?
0 out of 0 found this helpful

Need further help? Contact our Support Team