I have a Select_One field in a Repeat group and I would like to be able to prevent users from selecting the same answer twice in different instances of the Repeat. Specifically, it is a plant species list, and once a user has entered details (area covered) for a particular plant species, accidentally entering it twice would mess up the calculated results (total plant coverage). There may be multiple ways to achieve this, but I would imagine the easiest might be an expression in the Constraint column that either requires a Unique response or excludes a Duplicate response in that particular field. Another option might be to create a type of Select list that removes answers as they are selected, but the Constraint option would likely be more versatile, as it could by applied to Text and other types fields as well.
Hi Camille...
I like your idea.... it would make plant species data collection easier for I too.... \
A possible solution to your problem and mine.... would be to make it possible to restrict duplicates and copy the plant names from the repeat before into the next repeat....
Referencing each plant by position within each repeat has the potential to identify if there are duplicates within your repeats....
Thanks for submitting your idea!
I was able to apply a constrain to the select-on field using a constrain with the following steps:
1.- Calculate a join of the field: ej join('',${fieldselectone})
2.- Calculate isrepeated field inside the repeat using a regular expression: regex(join('',${fieldselectone}),concat('^[0-9]*(',${fieldselectone},')[0-9]*(',${fieldselectone},')[0-9]*$'))
Just note I'm using numbers [0-9] as the character set because on my case the ${fieldselectone} is a numeric code list, you could replace this wit [A-Z] or [A-Z0-9] for alpha
3.- Apply the isRepeated field as constrain on the ${fieldselectone}. Ej not(boolean-from-string(${isRepeated}))
I hope it works for you.
Regards,
Daniel R.
I was doing this before I found this post. Issue is that the item gets added to the check list immediately - which then throws an error.
So what I did is take the last few chars off the join list and check that. Works great until you go backwards a few repeats and try to change the value.
I wish there was a strcount to count how many are found.
Has anyone gotten this to work in the web form? It only displays the response within that repeat whereas in the app and Connect, all responses are displayed as expected. Someone suggested putting the original join - join('',${fieldselectone}) - outside of the repeat, but that still does not work.
I have not tried the web app. But I have one join inside the repeat with a once() around it for the check to work.
Then I have a second join outside the repeat for the user to see all responses.
Note in newer versions of 123 I had to add the first repeat as a special case since it loads that value right away but on repeat 2+ it does not. I reported this but 123 team did not think it was an error. So I use count to get around it. In this one I also added a comma to the check so that ABE and ABE4 do not get confused.
Hope that helps
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.