Generating a household ID in ODK Collect

Hi,

I intend to provide a function in my form coding by which the field workers could generate a unique household ID through ODK collect, and assign it to the household during their field visit. I have state/district/township lists with pre-decided codes in the form. How can I introduce a function which could generate some ID, and keep it unique across different data entry submissions for the same form (in other words, different households info... Since for every household, the FILL NEW FORM is started again).

Thanks,
Saad

Hi @Saad

If I understand your post correctly, a single form is used to collect data for a single household. So one approach I can recommend is using the uuid function with a length parameter to generate a random string and then use that string, possibly concatenated with your state + district + township codes, as the form's instance name.

This however will not allow the data collectors to be involved in the HH ID generation and it will be done internally.

But it will allow them to see and identify different forms for different HHs when they open the form using Edit Saved Form.

e.g. You will have a calculate field in your survey sheet with the calculation set as once(uuid(5))
this will create a random string with a length of five. You will then use this id in your settings sheet, under the instance_name column as concat(${state_code}, '-', ${district_code}, '-', ${town_code}, '-', ${hh_uuid}), hh_uid is the ID generated in the survey sheet.

I hope this helps.

1 Like