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
Solved! Go to Solution.
No this would be a limitation. If they go back and start editing previous repeats all kinds of stuff would probably break in my form. We tell the crews if they mess up a plant just delete that repeat and add a new one at the end. Then we are ok. The workflow is just them walking around and log what plants they see. So no real reason to go back through the list.
Hi @AndrewPadilla ,
I have tried to use the javascript code in a ' myFunctions.js'
function HasDups (myArray){
return new Set(myArray).size !== myArray.length;
}
but I have a error in the script called "Expected token ;" If you know what the error is, could you tell me a solution
Thanks
Hi @AndreaBaquerizo,
I am not an expert in writing JavaScript but it looks like you have the formula correct as pasted above but the screen shot you attached does not match. You need to remove the space between "(myArray)" and ".size", and also add a space between ".size" and "!" (see attachment). Easiest way would be to copy and paste the original formula. I attached a screen shot of my .js file. I hope that helps.
The JS fuction works great it my dev version of my survey, but as the production version will be a public survey I just realised its not going to work! Is there another way to achieve the same result? Within the repeat the user has a list of 12 target speices to survey and count, I dont wan them counting the same species twice as a seperate record.
Cheers
Chris
@DougBrowning I had a question about your way of checking for duplicates. Does it work in the Survey123 Web app? I have something working in the mobile app version, but it doesn't work in the web app survey. I am not using a javascript file. Any Thoughts? Thanks!
I would think it would work. I do not use the web much. One common gottcha in the web is + does not work to combine strings. You have to use concat(). Best thing is to post the form.
I see it works in Connect fine
Sorry I have no idea on the web. I do not see anything but I never use the web forms so I really do not know. Maybe someone else will. Sorry
Oh wait I see you are using reserved words. These little green boxes mean not cool. Could be it.
Also not sure you can start a field with a special char. Prob not
_size
Hope that does it
I made some of those changes, but with no luck. Thanks for all your help. I might have to make a call into esri support to see what might be wrong.
Thanks again,
GH
Did you publish it as a all new layer? If not those fields would still be in the service and could still cause issues. Its worth a shot.