Persist variable values


If enabled, all variables will be saved to Local Storage when the value in any control is changed.

If the Persist variable values property is enabled, the component will saves variable values to Local Storage whenever a value changes in a control, such as editing a TextBox or selecting a value from a DropdownBox control. For example, if the user is making changes to a record using a List Detail View and exits the app, their changes are retained in the Detail View controls -- even if they do not save them before leaving the app. When the user returns to the app, the variables can be restored, allowing them to continue from where they left off.

The following properties are exposed when Persist variable values is enabled:

Persisting Variables

Variables are persisted whenever a 'trigger' event occurs. For some controls (e.g. Radiobutton,. Checkbox, Slider, etc.), the 'trigger' is when the value in the control is changed. For textbox and textarea controls, the 'trigger' is when the control is blurred (i.e. loses focus) and the value in the field has changed.

You can also manually trigger the event by calling the UX component's {dialog.object}.persistVariablesToLocalStorage() method.

When variables are persisted to Local Storage various client-side events are fired.

The onBeforePersistControlValuesToLocalStorage event fires first. This event fires before the variables are persisted. Its purpose is to allow you to specify any additional data that you want to persist along with the variable values. Your code can set the e.userData property. The value you set in this property will be available when the onRestoreVariablesFromLocalStorage fires.

The localStorageEncryption event fires next. The event allows you to add your own encrypting to the JSON data that is about to be stored to Local Storage. The event handler gets the JSON data in the property and the event handler can set to the encrypted string.

When the component is loaded if the Restore variables from Local Storage setting is true, then the previously persisted variable values (if any) will be restored.

The onRestoreVariablesFromLocalStorage event will fire after the data has been restored. This event handler can access the e.userData property which was optionally defined when the onBeforePersistControlValuesToLocalStorage event was fired.

If the 'Restore variables from Local Storage' property is set of false, you can still manually restore persisted variables by calling the UX component's {dialog.object}._restoreVariablesFromLocalStorage() method.

See Also