In a workflow where fields entered in a registration form are concatenated to create a unique ID (IE municipal and district IDs, date of birth, first two digits of first and last name, etc) and saved, is there a way to check the saved ID case property against the other existing IDs of the other cases to ensure you're not creating an identical ID?
I don't think there is a way to actively check (especially given the offline functionality).
The best design solution I can think of is:
- The domain must be on the Standard Plan for User as a Case to be available
- Add custom user data number for each mobile worker (e.g. mobile user 1 = 01, mobile user 2 = 02)
- Add a counter that would increment for each case registered by each mobile worker
- Add the custom user data+counter number to each of the UIDs for the cases (e.g. the first case registered by mobile user 1 would be 011 = user case property + counter number)
The method Ben and Claire describe is probably the safest. But be aware that there are limitations if you have two people using the same username on different phones (since they'd be updating the same counter).
You could actively check if the id exists already for any cases that are currently on the mobile worker's phone with an xpath statement:
count(instance('casedb')/casedb/case[your_id_property = /data/id_entered] > 0)
This would let you know if there are any cases currently on your phone with that id. But would miss any closed cases or cases owned by others. So it also has drawbacks.