Overview

Custom User Data is an advanced tool that enables you to store and reference additional information about your mobile workers. By default, when you register a new mobile worker you can specify their username, first name, last name and password. Custom User Data allows any number of additional fields. For example, you could create a category of user, additional location data, or other metadata.

Usage

Custom User Data is useful if you want to be able to reference additional information about users in forms or cases.  For example, you may automatically want to store the user's district or village as part of any cases they register to make future data analysis easier.  

Introduction Video

View the introduction video for Custom User Data

Configure Custom User Data

In this stage you must define what data fields you want to collect for each mobile user.

  • On CommCareHQ navigate to Users -> Mobile Workers.
  • Click on the "Edit User Fields" button in the middle of the screen:

You will be brought to Edit User Fields page:

On this page you have the option of adding fields to collect for mobile workers. For each field you will need to define the following:

  • User Property: The unique ID you can use to reference this property in the application builder. The property may not contain spaces. This field is analogous to a "Question ID" in the form builder.
  • Label: The field label that users will see when adding or editing a User in CommCareHQ.
  • Required: Indicates whether this field is required for each user. If it is marked as required then you will not be able to create a mobile worker without filling in this field. It will also show up on the main "create mobile worker" page.
  • Choices: If you want to pre-define choices to appear as a dropdown, you can add those choices here.

To add a new field click on "Add New Field" and fill in the User Property and Label fields.

To remove a field click on delete - but note that if you delete a field that has already been populated for users, the next time that user's information is updated, any data collected for that field will be deleted as well.

You can change the order of the fields by dragging the vertical arrows on the left side of the screen.

Here is an example with three user properties:

This configuration would then update the Mobile Worker Registration Page to look like:

 

Add Custom User Data

There are two ways to add custom user data - through the Mobile Workers section of CommCareHQ, or through Bulk Upload

1 - CommCareHQ Mobile Workers Page

After you configure the user data, each time you add a new mobile worker the CommCareHQ user will be prompted to populate the field, in addition to the standard username and password fields. Required fields will have to be populated at time of creating the mobile worker, while other fields are optional. These can be filled-in during registration, or when editing a worker account.

 

 

B - Bulk User Upload

This feature requires a CommCare Software Plan

This feature (Bulk User Management) is only available to CommCare users with a Standard Plan or higher. For more details, see the CommCare Software Plan page.

You can use the Upload Mobile Workers in Bulk tool to add and update custom user data in bulk.

Before using the spreadsheet to update user data you will need to follow the instructions above to set up your user fields.

  1. Download the your current users excel file
  2. Add data to the custom user data columns and any other fields you want to populate.
  3. Save and upload it!

Notes:

  • You cannot add new user data fields by just adding a new column in the Excel file. You must use the edit user fields page to set it up.
  • If a field is required and you upload a spreadsheet that does not have a value for that field for all users, the upload will fail.
  • If you change the Custom User Data for a user, the new values should sync down to the user's phone, any time the user syncs with the server as long as the user has filled in at least one form since the last sync.

Using Custom User Data in an Application

Storing Custom User Data in a Hidden Value

You will have to reference the user data through the commcaresession.  The format is generally instance('commcaresession')/session/user/data/custom_user_data_name

So for example, to put the value of the custom user data village in a hidden value, add the following to the calculation: 

if(count(instance('commcaresession')/session/user/data/village) > 0, instance('commcaresession')/session/user/data/village, "Unknown")

 

Use a Custom User Data in a Display Condition

For example, to only show a particular question if the user is a supervisor (using the custom user data is_supervisor), add the following to a question's display condition.  Replace is_supervisor with the name of your custom user data and yes with the value you want to check for. 

count(instance('commcaresession')/session/user/data/is_supervisor) > 0 and instance('commcaresession')/session/user/data/is_supervisor= 'yes'

Accessing Phone Number and the User Name

The user's first and last name, and phone number are also available through custom user data. They are automatically added to the data:

  • commcare_first_name
  • commcare_last_name
  • commcare_phone_number


For example, to combine the user's first and last name into a single name in a hidden value, you can do the following:

concat(instance('commcaresession')/session/user/data/commcare_first_name, " ", instance('commcaresession')/session/user/data/commcare_last_name)

 

  • No labels