Avoid ID duplicated

Following the explanations received to avoid duplication of ID numbers, I tried but I am having some difficulties :
All fields are on a simple form that registered a new case.

  • The ID field number "Numero_individu" is in text format and is scanned by the mobile user. I created a hidden value "previous_num". My files type is "Prelevement". In user case management, I load *Numero_individu in *previous_num. I used the following validation condition: count(instance('casedb')/casedb/case[@case_type = 'Prelevement'][ Previous_num = Numero_individu ]) = 0. When I scan an individual number K31284 in a form that I submit and just after I scan the same number K31284 in another form, a message appears indicating the risk of duplication.

But after submitting the form with the number K31284, if I submit several forms with different individuals numbers and then I still scan the number K31284 that had been used instead, it no longer detects the duplicate.
I ask for your support and expertise.
Thank you

Hi Felix,

Off the top of my head I'm not so sure why that wouldn't work. One thing
you could try is displaying the output of this expression in the
form: count(instance('casedb')/casedb/case[@case_type = 'Prelevement'][
Previous_num = Numero_individu ]) under different scenarios and see if you
can use that to figure out why it's sometimes 0 when you aren't expecting
it to be.

It might be easier to troubleshoot if you make Numero_individu a text
property that you can change in real time.

Hope that helps get you unblocked!

Cory

ยทยทยท On Fri, Jul 29, 2016 at 2:40 PM, 'Tarbangdo Felix' via commcare-users < commcare-users@googlegroups.com> wrote:

Following the explanations received to avoid duplication of ID numbers, I tried but I am having some difficulties :
All fields are on a simple form that registered a new case.

  • The ID field number "Numero_individu" is in text format and is scanned by the mobile user. I created a hidden value "previous_num". My files type is "Prelevement". In user case management, I load *Numero_individu in *previous_num. I used the following validation condition: count(instance('casedb')/casedb/case[@case_type = 'Prelevement'][ Previous_num = Numero_individu ]) = 0. When I scan an individual number K31284 in a form that I submit and just after I scan the same number K31284 in another form, a message appears indicating the risk of duplication.

But after submitting the form with the number K31284, if I submit several forms with different individuals numbers and then I still scan the number K31284 that had been used instead, it no longer detects the duplicate.
I ask for your support and expertise.
Thank you

--
You received this message because you are subscribed to the Google Groups
"commcare-users" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to commcare-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.