Can I prevent a value from being submitted multiple times in a repeat question?

9113
35
Jump to solution
06-14-2019 11:30 AM
LaurenMcGarvey
New Contributor II

I have a repeat question in my survey as shown below.  

The repeat question is to document the plant species and cover class in a quadrat.  There are over 200 values for plant species and many species may be found in a quadrat.  Is there a way to prevent a plant species from accidentally submitted multiple times in the repeat question?

0 Kudos
35 Replies
LaurenMcGarvey
New Contributor II

This worked great!  Thanks for sharing!

DougBrowning
MVP Esteemed Contributor

Sorry I forgot to change all the field names from SpeciesList to species but I guess you got it.  Note this does assume your codes are 4-5 characters long.  That is why I take off 3 chars then check the string (this is because it will try to check the species you just added).  The check for "" was so that users could go backwards without having to delete the current repeat due to the required.

SPNIOrganization
Occasional Contributor

Hi Lauren,

Can you please post the final xls form and js file that worked for you?

I'm trying to do exactly what you did, with no success.

thanks,

Dikla.

0 Kudos
sim0ne
by
New Contributor

Lauren, could you share how you got this to work? I'm having the same issue!

0 Kudos
ElbaMolina
Esri Contributor

Hi Doug Browning, I used your form with my own data, but I have a doubt about distinct check, if it really does something, because I deleted it and my form worked fine. 

I have another challenge that is to limit the count of repeats from the number of occurrences of a list, for example: If I choose an option that has 3 choices (cascade) and by the other hand I have other option that has 4 choices, I want that, in the first case, only let me add 3 repeats, and second case 4 repeats. I did it using pulldata to get the number of choices and add repeat count, but repeat count doesn't let me deleted submitted answers.

Any suggestion?

Thank you

0 Kudos
DougBrowning
MVP Esteemed Contributor

I have seen a lot of weirdness changing repeat_count on the fly.  It basically erases and rebuilds the repeat on each change.  So nothing I tried worked.  In the end I instead did a count on the number of repeat values and then put a constraint on that number.  I am not sure what you mean by deleting submitted answers?  Is this a repeat in a repeat or something?  i think I heard a field will work in repeat_count but not pulldata?  Not sure but try pulling form a field instead with the pull data in that field.

My code for sure works to stop dups, been using it for years.  Maybe post up or send me a sample sheet.  Not understanding your post.

0 Kudos
ElbaMolina
Esri Contributor

Sorry Doug Browning my explanation was weird haha.

I attached my survey; in media folder there is a csv file that I use for pulldata.

When you choose an option of "Seleccionar una region", it changes Pasos Fronterizos, and you can choose one of them, it's a cascade selection:

if you choose twice the same paso fronterizo, appears a constraint message.

when I try to back, without repeat count, the repeat allows me delete the entrance.

but I need to limit the numberof repeats based on "pasos fronterizos" number.

Thanks!

0 Kudos
DougBrowning
MVP Esteemed Contributor

Are you trying to collect multiples at one time? Or do they select one region and then fill out the repeat.  Then a new form?

0 Kudos
LeonardBarnhill
Occasional Contributor

Good morning, I know this is an older blog but did you ever get any response to your query about limiting the number of repeats based on user response to a specific question?  I have been trying to do this without success - If a manhole has 3 pipes, I want a repeat for each pipe.  If it has 4 pipes, I want 4 repeats to be presented so the user could be required to complete all 4 repeats. 

I am also trying to the limit the pipe count options available to the user which is what brought me to this particular blog.  The DistinctCheck for length is of no value when all options are only 1 digit in length.  For example, the first pipe should always be the outflowing pipe.  I do not want users to be allowed to use "1" for any other pipe. 

Back to the first part of this question, If I can limit the number of repeats maybe I no longer need the pipe count and could autopopulate the flow direction to "outflow" on the first repeat

0 Kudos
JosephBusalacchi
New Contributor

Phil,

I am having the exact same issue working on a very similar survey.  I am trying to provide a warning if the data collector tries to add the same species twice in one plot.  I have added the distinct_check java script and the message is always on.  Could you possibly explain to me how to organize this code correctly in the Survey123 Connect spreadsheet to only show the message when there is a repeat?

0 Kudos