I’m using a registration form (Prelevement) where a have a ID field called (Participant_id). I want to detect a duplicate number for this field where the mobile worker submit a form.
It sounds like a classic challenge with data entry - duplicates can be a real headache to clean up after the fact.
One thing that might help is checking if you can use a validation condition or a calculation to flag existing IDs during the registration phase. If you can set up a "lookup table" or a search requirement before the form is even submitted, it usually saves a lot of time compared to trying to merge cases later. It's a bit of extra work on the front end, but it definitely keeps the data cleaner in the long run.
Great question, and I can help clarify the issue with your validation condition!
The Problem:
As Mazz correctly pointed out, the issue with your validation condition is that both instances of Participant_id are referencing the same thing. You need to reference the form field you're currently entering (using the correct path to your form question) when comparing it against existing case data.
The Fix:
Your validation condition should look something like this:
The firstParticipant_id (after [Participant_id =) refers to the case property in your existing cases
The second part should reference the actual field in your current form being filled out
How it works:
This validation checks if there are any existing cases of type "Prelevement" where the Participant_id case property matches the value being entered in your form. If the count equals 0, it means no duplicates exist and the validation passes.
Additional Suggestion:
As Eris_Casper mentioned, you might also want to consider using case search functionality to allow mobile workers to search for existing participants before creating a new registration. This can be a more user-friendly approach than just blocking duplicates with a validation message.
Let us know if you need help with the exact XPath path for your form field, or if you'd like guidance on setting up case search instead!