Select to view content in your preferred language

Constraint on select_multiple answers

3822
10
Jump to solution
01-16-2019 12:47 AM
Nicole_Ueberschär
Esri Regular Contributor

I wonder how I can check on not allowed combinations of select_multiple answers. 

For example: I have a list of multiple choices (category): none, covered, uncovered, vip. If none is checked, the others should not be applicable, for the others any combination is possible. It seems awkward to list all possible combinations as a constraint.

I was thinking of something like  if(selected(${category},'None') then count(${category}) has to be 1 but how do I put this as a constraint?

Thanks in advance!

0 Kudos
1 Solution

Accepted Solutions
Jim-Moore
Esri Regular Contributor

Hi Nicole

Great idea for the constraint. A similar query came up on GeoNet recently - the constraint syntax below might be of use? (With thanks to James Tedrick‌.)

if(selected(${category}, 'None') and count-selected(${category}) > 1, false(), true() )‍

Cheers,

Jim

View solution in original post

10 Replies
Jim-Moore
Esri Regular Contributor

Hi Nicole

Great idea for the constraint. A similar query came up on GeoNet recently - the constraint syntax below might be of use? (With thanks to James Tedrick‌.)

if(selected(${category}, 'None') and count-selected(${category}) > 1, false(), true() )‍

Cheers,

Jim

Nicole_Ueberschär
Esri Regular Contributor

Thanks a lot! Looks like logically I wasn't too far away from the solution

Jim-Moore
Esri Regular Contributor

Very close!

0 Kudos
HaroldHerrera1
Frequent Contributor

Hi!

I'm trying to use the constraint in the same question to refer to, and It doesn't work... I'm looking this post  and works fine, with some modifications, for example, refer to many options:

not((selected(., 'option1') or selected(., 'option2') or selected(., 'option3') or selected(., 'option4') or selected(., 'option5')) and selected(., 'option6'))

0 Kudos
Dudley_R_Hartel
Occasional Contributor

I've added this constraint (based on your example) if(selected(${TreeFailureResult}, 'NONE') and count-selected(${TreeFailureResult}) > 1, false(), true() ) for my select_multiple but it doesn't trigger my constraint message "<b>None</b> can't be selected with other choices."?

I was also trying this approach (from an older GeoNet thread) to no effect: not(selected(., 'NONE') and (selected(.,'FIRE') or selected(.,'LOSL') or selected(.,'LOST')  or selected(.,'OTHR') or selected(.,'PERS') or selected(.,'UTIL') or selected(.,'PROP') or selected(.,'PRUN') or selected(.,'REMV')))

I'm testing this in Survey123 Connect (not by publishing and using in the Survey123 App).

Dudley_R_Hartel
Occasional Contributor

I published that form change and the constraint message doesn't appear in "real-time", but only after I try to submit the form! So that can work - not quite what I was expecting.

Is there a "real-time" solution, so that when I'm in the a select_multiple question the form would prevent NONE with other checks and NOT have to wait til I submit?

Multi-select example

0 Kudos
Dudley_R_Hartel
Occasional Contributor

Optimally, if I check 'None" and then check some other list item, the 'None' would get unchecked?

0 Kudos
JamesTedrick
Esri Esteemed Contributor

Hi Dudley,

By 'real-time', you are asking for about option-by-option validation of the select_multiple question?  Currently, this is not supported in Survey123.

0 Kudos
Jim-Moore
Esri Regular Contributor

Hi Dudley

One option could be to use the constraint as described, but also have a note that appears immediately below the select_multiple to warn the user when they've selected 'NONE' and one or more other choices, e.g. add selected(${TreeFailureResult}, 'NONE') and count-selected(${TreeFailureResult}) > 1 to the relevant column for the note.

Alternatively, you could add a preceding question to control if the user sees the select_multiple, as described here.

Jim