Select to view content in your preferred language

Do not repeat previous answer in a repeat group

574
3
03-21-2019 12:31 PM
ChantaleCarrier1
Esri Contributor

Hi,

In a form for an inventory made with many groups and sub-groups, I have a repeat to enter many species. I must enter one specy per repeat and do not have the same specy entered twice for a parcel. Specy is entered from a select_one list presented as an auto-complete list.

I'm trying to do that if a specy is entered in the first repeat and that I try to enter it again in repeat 25,I could not enter it in 25 by being advertised by a color, by a text, or being unable to choose the same specy an other time during the repeats.

Example:

values entered

Repeat 1= Abies ×phanerolepis

Repeat 2= Abies balsamea

Repeat 3= Acer pensylvanicum

...

Repeat 25= try to enter again Abies ×phanerolepis and seeing in color, being advertising that it is already in the previous answer of Repeat 1 to 24, or something like this. Another way could be to remove from list the answers previously added.

Any idea how to do it?

Thanks,

0 Kudos
3 Replies
JamesTedrick
Esri Esteemed Contributor

Hi Chantale,

This is possible by using a combination of the 'join' function to get a list of the values that have been entered and the regex() function to check for 2 or more entries of the current repeat.  See the attached example.  To break down the regex pattern:

regex(join(",",${prov_terr}), concat("(.*", ${prov_terr}, ",?.*){2,}"))

  • join(",",${prov_terr}) - creates a list of the selected items in the repeat
  • concat() - joins the sub-parts of the regex term together, using the current field value.  If British Columbia had been selected, it would become (.*BC,?.*){2,} , which I will use below
  • (.*BC,?.*){2,}
    • ( ) - everything inside the parenthesis is one thing to match
    • .* - match anything, including no characters
    • BC - match the letters BC
    • ,? - an optional match for a comma
    • .* - match anything, including no characters
    • {2,} - have at least 2 matches

Note that there is currently an issue with Survey123 raising constraints when the first value in a repeat sequence is valid.  As a substitute, you can have a warning note appear to alert the user the value has already been entered.

0 Kudos
ChantaleCarrier1
Esri Contributor

Thanks James,

If the values (species) are coming from an external database by a pulldata function, how should I add it in the function?

Ex.: A .csv that include species only 

Thanks for your help!

0 Kudos
JamesTedrick
Esri Esteemed Contributor

The method of where the species comes from shouldn't matter, just the check for identical values in the answers.

0 Kudos