There may be times you want to store values on the device to reuse in the same screen or in multiple screens. For example, if you have a common field in several form screens that the user has to select each time - e.g. a project, client or job number then you should consider storing this in a global value.

Global values let you specify that a form field should get its default value from a new key/value store that exists on the device. The functionality works as the name says, its globally accessible storage across all screens on a specific device.

At this time, only the form screen can leverage this option. We'll be introducing it to other screens shortly! 

Let's consider an example:

You have a screen that has a project field and a site field. The project must be chosen first from the list of available projects, this will then filter the site field with the available sites for that project.

1. On your project field, set the 'Bind to Global Value' property to be a name of your choice - e.g. 'defaultProject'.

2. On your site field, set the 'Bind to Global Value' property to be a different name of your choice - e.g. 'defaultSite'.

3. Save and set the form into test or published mode.

When an entry for this form is uploaded, the app will now automatically save the answer for project into the global values key of 'defaultProject', and similarly it will do the same for 'defaultSite'. The app has effectively created a local dictionary/lookup that looks like:

defaultProject = 'Last project the user selected'

defaultSite = 'Last site the user selected'

When the user next opens your form, these global values will load and default into the respective project and site fields, remembering the last selected values for those two fields. Similarly, you could now also set project & site fields in other forms to bind to the defaultProject & defaultSite global values.

The same behaviour as above will occur when the user opens these forms. They will see that project and site is preset. This is great for times where you want to have a persistent project & site context for the user across multiple forms.

Using global values in a formula

You can also use a global value in a formula. You can use the GLOBALVAL('keyname') formula function. All global values are stored as text. If you use GLOBALVAL() as an assignment to a date/time or number field, then you will need to convert the value to the correct datatype of the target field. This is done using our TODATE() and TONUMBER() functions respectively.

Did this answer your question?