Checklist validation

I have a checklist which includes these two options:

  • None (Choice Value = 'services_none’
    and
  • Don’t know (Choice Value = ‘services_unknown’)
    plus other options

If either one of these is selected then I want to validate to make sure no
other item is selected.

I’ve tried various bits of syntax but can’t seem to get the logic right.

Currently I have the following in the Validation Field:

(. = selected(.,‘services_none’) and count-selected(.) > 1) or (. =
selected(.,‘services_unknown’) and count-selected(.) > 1)

But this isn’t working.

Guidance would be gratefully received.

Simon

Hi Simon,

“selected(.,‘services_none’)” returns a boolean value so “. selected(.,
‘services_none’)” is not (I think) what you want. Try:

not(selected(.,‘services_none’) and count-selected(.) > 1) and not
(selected(.,‘services_unknown’)
and count-selected(.) > 1)

or simplifying:

not( (count-selected(1) > 1) and (selected(.,‘services_none’) or
selected(.,‘services_unknown’)
) )

(Syntax might be imperfect)

Cheers,
Will

··· On Sun, Mar 5, 2017 at 3:18 PM, Simon Berry wrote:

I have a checklist which includes these two options:

  • None (Choice Value = 'services_none’
    and
  • Don’t know (Choice Value = ‘services_unknown’)
    plus other options

If either one of these is selected then I want to validate to make sure no
other item is selected.

I’ve tried various bits of syntax but can’t seem to get the logic right.

Currently I have the following in the Validation Field:

(. = selected(.,‘services_none’) and count-selected(.) > 1) or (. =
selected(.,‘services_unknown’) and count-selected(.) > 1)

But this isn’t working.

Guidance would be gratefully received.

Simon


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.

1 Like

Thanks William.

Your syntax was perfect!

Regards

Simon
5/3/17

··· On Sunday, March 5, 2017 at 5:10:12 PM UTC+3, William Pride wrote: > > Hi Simon, > > "selected(.,'services_none')" returns a boolean value so ". selected(., > 'services_none')" is not (I think) what you want. Try: > > not(selected(.,'services_none') and count-selected(.) > 1) and not (selected(.,'services_unknown') > and count-selected(.) > 1) > > or simplifying: > > not( (count-selected(1) > 1) and (selected(.,'services_none') or selected(.,'services_unknown') > ) ) > > (Syntax might be imperfect) > > Cheers, > Will > > On Sun, Mar 5, 2017 at 3:18 PM, Simon Berry <si...@colalife.org > wrote: > >> I have a checklist which includes these two options: >> >> * None (Choice Value = 'services_none' >> and >> * Don't know (Choice Value = 'services_unknown') >> plus other options >> >> If either one of these is selected then I want to validate to make sure >> no other item is selected. >> >> I've tried various bits of syntax but can't seem to get the logic right. >> >> Currently I have the following in the Validation Field: >> >> (. = selected(.,'services_none') and count-selected(.) > 1) or (. = >> selected(.,'services_unknown') and count-selected(.) > 1) >> >> >> But this isn't working. >> >> Guidance would be gratefully received. >> >> Simon >> >> -- >> 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-user...@googlegroups.com . >> For more options, visit https://groups.google.com/d/optout. >> > >