Create unique id for participant


I am creating a survey form. I would like to create an unique id of each woman. How could I create woman_id as unique identifier?
NarendrademogForm.xlsx (18.9 KB)


Hi @nstharkuri!

So each form will get a unique id (uuid) that you can call on. I would suggest using that to start with. Alternatively, if you have to create a unique id variable that is some combination (like we did household id + line number within household) you can do something like this: quest1_03_0.xlsx (55.2 KB)



Are you looking to re-use the ID for multiple longitudinal surveys?


Thanks @elmps2018,
@ghare, Yes I am creating the multiple longitudinal survey. The enrollment form would capture an unique woman ID for only one time. we need to validate that each woman_id is only used one time. Could you please suggest.


There are a couple options here:

  1. Preload the ids and not let enumerators edit them; then they will necessarily be unique.
  2. If they need to be created in the field, you can check that an id is used once and only once using async_assign. For example, in section 2_2 we check that everyone enters data for one and only one father with zcheck_father: quest2_00_0.xlsx (723.1 KB)
    Here's a zip with the async_assign: (2.5 KB)

You need to set up a query (here, count_fathers) and then async_assign_count can count them.

There's probably some more efficient method as well, but this would at least let you count instances of an id and make sure there is one and only one with a constraint.



Thanks @elmps2018,
We will assign unique womanID for each woman in the field and data collector inserts into the tablet. We want to prevent womanID duplication when collecting data. When we create an enrollment form for women and each woman gets an unique womanID.
After reviewing your example, do we need to create a separate table for father enrollment?


Hi @nsthakuri!

I think the question of whether you need to do tables and unique ids for fathers really depends on what your data needs are for the project (are you trying to track fathers over time?).


Hi @elmps2018,
We are going to conduct a study, initially we will enroll women through demographic form. Our data collector will insert womanID manually into the tablet. But sometime data collector could mistakenly enter womanID that was previously used. In this situation, we would like to generate alert for data collector to prevent duplicate woman ID.
For example, womanid 123 was previously assigned to woman 1. But data collector could assing with type same womanid 123 to waman 2. Here we would stop enter same womanid.


Hi @nsthakuri,

So you can do exactly what you want by changing the count of the fathers to be the count of women ids in your case. The structure is that async_assign counts ids, and then there would be an error message based on the constraint if there are multiple uses of the same id.


Thanks @elmps2018,
I'll try.

1 Like

Hi @elmps2018,
I tried it but not able to get it. Could you please guide that how to link js file: customPromptTypes.js


Hi @nsthakuri!

The custom prompt types file should be in the same folder as the formDef.json using it; so in ⁨app⁩ ▸ ⁨config⁩ ▸ ⁨tables⁩ ▸ ⁨questionnaire_whatever ▸ ⁨forms⁩ folder.

Hope that helps!


Hi @elmps2018, demogForm.xlsx (20.1 KB)

I have changed woman_id to async_assign_count type. Also put custom prompt type js file in same folder. Is this enough to put in the same folder? I’m still struggling with this issue. I have attached my files. Async_assign.handlebars temple file path has been written in customPromptTypes.js file. Do we need handler file too?


Hi @nsthakuri!

So I think the file is in the right place and I didn't have any additional handler files.

One issue in your file is that your variable name, woman_id, is circular. You need to create a variable like count_woman_id and async_assign that variable, and constrain that variable to be one. Currently you are assigning the count to be woman_id, which is not what you want.

1 Like