Cascading updates with two Select One Lists

98
4
Jump to solution
09-21-2018 10:33 AM
New Contributor III

Hello!  I've worked with Survey 123 a bit, and have experience updating a text field based on a change in a Select one Drop down list. This works great!

I have another requirement now for a 2-way update between two select_one drop down lists, and pulldata doesn't seem to work in this instance.

I have two Select Lists, with species scientific name, and then common name.  What we want is, if either of the two lists are updated, the "other" name for the sighting will be updated. It could work both ways.  A user could enter either the common name or the Latin name, and have the other one update.  Using the same pulldata approach didn't do this.

I thought I read somewhere that this was not supported until v3.  I upgraded and can't get it to work.  Any thoughts? Thanks!!

Reply
0 Kudos
1 Solution

Accepted Solutions
Esri Esteemed Contributor

Hi Greg,

What you are describing can't be implemented in Survey123 - cyclical calculations (if a is set, set b; if b is set, set a) aren't allowed in a form (while they might be able to work in this case, if involved with a mathematical calculation this could lead to an endless loop of calculations).

James

View solution in original post

4 Replies
Esri Esteemed Contributor

Hi Greg,

What you are describing can't be implemented in Survey123 - cyclical calculations (if a is set, set b; if b is set, set a) aren't allowed in a form (while they might be able to work in this case, if involved with a mathematical calculation this could lead to an endless loop of calculations).

James

View solution in original post

New Contributor III

Thanks James!   Do you have any suggestions for a workaround for a scenario like this?  They would like the ability to update the species record with either the common or Latin Name..... Cant' think of a way to do this without drop down lists! Thanks for your help!

Reply
0 Kudos
Esri Esteemed Contributor

Hi Greg,

A couple of options:

1) You can include both the common name and scientific name in the same label; an autocomplete appearance will let the user type in either

2) You could have a survey with 3 dropdowns:

- q1: Search by Common or Scientific name?

- q2: Common Name search (relevant when q1:common is selected)

- q3: Scientific Name search (relevant when q1:scientific is selected)

and a 4th question of type calculate to store the answer using coalesce() function to get the value from either questions:

coalesce(${q2}, ${q3})

The coalesce function returns the first non-null value in the presented from the two options.

Reply
0 Kudos
Occasional Contributor II

Instead of having the two questions try to populate eachother, make them both null and have them both populate a separate pair of read-only fields. I've attached a sample form that expands on an earlier example I provided on this exact workflow here.

The gist of it is that you have your two select_one questions (${SciName} and ${ComName}) and then two read-only text fields with the following calculations:

Scientific Name: coalesce(${SciName},pulldata('SpeciesNames', 'SciNam', 'ComNam', ${ComName}))

Common Name: coalesce(${ComName},pulldata('SpeciesNames', 'ComNam', 'SciNam', ${SciName}))

This does present the possibility of a user selecting both a scientific name and a common name and populating these fields with a mismatch. For that case, we add a constraint to either one of the text fields:

if((${SciName}!='' and ${ComName}!=''), (${SciName}=pulldata('SpeciesNames', 'SciNam', 'ComNam', ${ComName}) and ${ComName}=pulldata('SpeciesNames', 'ComNam', 'SciNam', ${SciName})),1=1)

This checks to see if both of your select_one questions are answered, and if yes, it makes sure everything matches correctly (the selected scientific name equals the pulldata from the common name, and vice versa). The else case, 1=1 (i.e. no real constraint), is triggered only if one, the other, or neither select_one is answered. The attached form also includes a note question with a similar calculation in the relevant column, which warns that there's a name mismatch.

Hope this helps!

Reply
0 Kudos