Often it is useful to have access to certain system data, such as username, case id, or the unique device id, from within form entry. This can be achieved via the CommCare session instance.

Device Data

TypePathDetails
device idinstance('commcaresession')/session/context/deviceidThe unique ID for the entering device
usernameinstance('commcaresession')/session/context/usernameThe username of the user entering data
user idinstance('commcaresession')/session/context/useridThe GUID of the user entering data
app versioninstance('commcaresession')/session/context/appversionThe identifier for the software application version performing form entry


Session Data-- Referencing the Caseid inside Form Builder

As you navigate through your mobile app to enter form entry, you will sometimes select cases. The ID of those cases are available in commcare session instance.

In normal workflows you only select one case. In such settings the case_id can be accessed using the instance('commcaresession')/session/data/case_id path.

If you are in a more advanced workflow (via advanced modules) you will be prompted for the 'case tag' of the case being loaded on HQ. If you set the case tag to 'load_mother' for example, then in the CommCare session instance you can access that case's id using the path instance('commcaresession')/session/data/case_id_load_mother

Custom User Data

It is possible to attach custom data to users in CommCare and access that information within form entry. Details found at the 'Custom User Data' page.

There are several custom values that are provided in the custom user data:

DataPath
User's first nameinstance('commcaresession')/session/user/data/commcare_first_name
User's last nameinstance('commcaresession')/session/user/data/commcare_last_name
User's phone numberinstance('commcaresession')/session/user/data/commcare_phone_number
User's primary locationinstance('commcaresession')/session/user/data/commcare_location_id