I would like to add several validation constraints on a a multiple
choice-multiple select question. Firstly, there should be no more than two
responses. Secondly, if 'none' is selected, there shouldn't be any other
responses. These each work separately, but I haven't been able to put them
together.
So far I've tried the following, with no luck:
count-selected(.) < 3 and (not(selected(., 'none' and count-selected(.) >
1)))
count-selected(.) < 3 or not(selected(., 'none' and count-selected(.) > 1))
Your first tried one looks close though I think you're missing a bracket
after the selected() function (surprised this wouldn't give an error when
you tried to build). I'd try:
count-selected(.) < 3 and not(selected(., 'none') and count-selected(.) > 1)
could also rephrase as an if which might be more legible/explicit:
···
On Tue, Jan 19, 2016 at 5:37 AM, Eric Jospe wrote:
I would like to add several validation constraints on a a multiple
choice-multiple select question. Firstly, there should be no more than two
responses. Secondly, if 'none' is selected, there shouldn't be any other
responses. These each work separately, but I haven't been able to put them
together.
So far I've tried the following, with no luck:
count-selected(.) < 3 and (not(selected(., 'none' and count-selected(.) >
1)))
count-selected(.) < 3 or not(selected(., 'none' and count-selected(.) > 1))
Thanks, Will! I tried the second one and it worked perfectly.
···
On Tuesday, January 19, 2016 at 6:02:35 PM UTC+2, William Pride wrote:
>
> Hi Eric,
>
> Your first tried one looks close though I think you're missing a bracket
> after the selected() function (surprised this wouldn't give an error when
> you tried to build). I'd try:
>
> count-selected(.) < 3 and not(selected(., 'none') and count-selected(.) >
> 1)
>
> could also rephrase as an if which might be more legible/explicit:
>
> if(selected(., 'none'), count-selected(.) < 1, count-selected(.) < 3))
>
> Best,
> Will
>
> On Tue, Jan 19, 2016 at 5:37 AM, Eric Jospe <eric....@gmail.com > wrote:
>
>> I would like to add several validation constraints on a a multiple
>> choice-multiple select question. Firstly, there should be no more than two
>> responses. Secondly, if 'none' is selected, there shouldn't be any other
>> responses. These each work separately, but I haven't been able to put them
>> together.
>>
>> 1: count-selected(.) < 3
>> 2: not(selected(., 'none' and count-selected(.) > 1))
>>
>> So far I've tried the following, with no luck:
>> count-selected(.) < 3 and (not(selected(., 'none' and count-selected(.) >
>> 1)))
>> count-selected(.) < 3 or not(selected(., 'none' and count-selected(.) >
>> 1))
>>
>> Any advice?
>>
>> Thanks!
>>
>> --
>> 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.
>>
>
>