Constraint on select_multiple answers

356
9
Jump to solution
01-16-2019 12:47 AM
Highlighted
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!

Reply
0 Kudos
1 Solution

Accepted Solutions
Highlighted
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

9 Replies
Highlighted
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

Highlighted
Esri Regular Contributor

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

Highlighted
Esri Regular Contributor

Very close!

Reply
0 Kudos
Highlighted
New Contributor III

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).

Reply
0 Kudos
Highlighted
New Contributor III

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

Reply
0 Kudos
Highlighted
New Contributor III

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

Reply
0 Kudos
Highlighted
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.

Reply
0 Kudos
Highlighted
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

Highlighted
New Contributor

To J. Tedrick: yes, by 'real-time' I meant an immediate response instated f waiting til validation.

To J. Moore: The note option is helpful (and I have now used that for other messages) -

Thanks to responses

Dudley's response under a different GeoNet login

Reply
0 Kudos