How to not use a list item more than once.

157
1
02-27-2019 07:32 AM
Highlighted
Frequent Contributor II

I have a select one list in a repeat where I want to stop, or warn, a user if they pick an item more than once during the repeats.  This list is about 1,300 items.

I created a field that keeps a running list from my repeat

join(", ", ${SpeciesList})

I tried this constraint on the list  not(contains(${AllPlants}, ${SpeciesList}))  but it always triggers since it is in the list as soon as i pick it.

Is there a way to count the number of string occurrences?  Or remove it from the check somehow.

Thanks for any ideas

Tags (3)
Reply
0 Kudos
1 Reply
Highlighted
Frequent Contributor II

I got this to kinda work but it has issues.  What I do is take off the last 3 chars of the running list, thus breaking up that last value - which is then not found.

not(contains(substr(${AllPlants}, 0, string-length(${AllPlants}) - 3), ${SpeciesList}))

If you go down the repeat in order this works.  But this falls apart if you go backwards in a repeat and try and change a value.

What would be nice is a count of the number of substrings found.  so substr("XXXXX", "X") returns 5 not just true false.  Or a contains that returns the position the string was found would work also.

Thanks for any ideas.

Reply
0 Kudos