What is the syntax for writing this validation logic? Option 1 AND (option 2 or option 3 or option 4)

Hi everyone,

On our select multiple questions, we need to prevent people from selecting
both 'none' and any other choice. How does CommCare support this option?

We keep getting errors when we try writing the logic in a few different
ways, like

. = 'nothing' and ('agronomy' or ‘not_farming’ or ‘other’)

Hello,

For multi-selects you will need to use selected()
https://confluence.dimagi.com/display/commcarepublic/CommCare+Functions#CommCareFunctions-selected
and count-selected()
https://confluence.dimagi.com/display/commcarepublic/CommCare+Functions#CommCareFunctions-count-selected
functions - this is because multi-selects store their answers as a space
separated list, so for example if you selecting 'agronomy' and 'other' the
answer will be 'agronomy other' and thus '. = agronomy' will be false.

In your case you would want (pseudocode) 'not(selected(., 'nothing') and
count-selected(.) > 1)' - so, if nothing is selected you cannot select
more than one answer.

Cheers,
Will

··· On Wed, Sep 27, 2017 at 9:42 AM, Alice Wang wrote:

Hi everyone,

On our select multiple questions, we need to prevent people from selecting
both 'none' and any other choice. How does CommCare support this option?

We keep getting errors when we try writing the logic in a few different
ways, like

. = 'nothing' and ('agronomy' or ‘not_farming’ or ‘other’)

--
You received this message because you are subscribed to the Google Groups
"commcare-users" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to commcare-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.