Context fields capture background (meta) data about the fieldworker and the current form, such as the fieldworker's name or the current version of the form. This information can be used to drive logic in the form or to capture and display it in the analytics.
To retrieve this 'background' data, you can reference context fields in your form by typing the dollar sign("$") and selecting the relevant context field from the drop-down. The table below lists the available context fields.
|$context.deviceId||Console identifier of device (blank if web collection)|
|$context.editorId||Console identifier of editing user (blank if capturing data)|
|$context.editorName||Name of editing user (blank if capturing data)|
|$context.fieldworkerId||Identifier of user capturing data (if available)|
|$context.fieldworkerName||Name of user capturing data (if available)|
|$context.formVersion||Current version of the form|
|$context.language||Current language of the form being captured|
Context fields can be displayed in the form by referencing the context field in the display text of any field as seen below.
Note: Information fields as in the example below are covered in our article on basic field types.
Or, captured and displayed in analytics and part of submission data as seen below.
Note: Calculated value fields as in the example below are covered in our article on advanced field types.
Context fields can also be used to drive logic in your form as explained in the example below.
Display participants that are assigned to the current fieldworker.
This is useful if you would like to filter and display the participants relevant to the fieldworker that is currently capturing the form. Participants assigned to other fieldworkers will not be shown in the list.
- Create a select field with an external source file (e.g. CSV file) that lists all the participants as well as the fieldworker that each participant is assigned to. Visit our article on Populating an option list from an external source for detailed steps on using and setting up a select field with an external source file.
- Select the source file and the column to be displayed (i.e. the option list to be displayed to the fieldworker). E.g. The full name of the participant.
- Use the 'advance filter options' feature to filter the participant list. Filtering options in select fields are covered in more detail here.
- To filter for the participants that are assigned to the fieldworker capturing the form use the following filters:
- Select the column that lists the fieldworkers (that are assigned to the participants). E.g. FieldworkerName
- Choose the column type, in this case the fieldworker's name would be Text
- Select the operator, in this case 'equal to'
- Add the context field, i.e. the fieldworker name that must be matched on: $context.fieldworkerName
Note: The fieldworkers' names in the CSV file should correspond with the names of the fieldworkers on the console. If they are spelled differently for example, they will not be filtered correctly.
Only participants assigned to the fieldworker will be displayed in the options list.
Tip: Select the Preview button from the toolbar to test your form and see how it will be displayed when using the mobile app.