Creating warning if particular choice not selected in repeat group

I am using a roster which collects name, age and relation to respondent and want to create a warning if the surveyor doesn't select relationship 'Self' for anyone in the roster. I have tried using an index repeat but this doesn't seem to work.

Hi @Prashansa_Srivastava,

I think you could somehow concatenate the responses and check if the selected option is included in the resulting string, but I think this would be a complicated and not very practical (also for the user).

The workaround I usually use is to force the first loop/respondent to be "Self" (or in other forms the "household head"). You can change the option list relationship not to include "Self", so you are sure that it appears only once.
You can play around with relevant conditions and calculate fields to ensure you consolidate the answers in a unique variable. E.g.
${relationship} calculate: if(${id)=1, 'Self', ${relationship_other})
where ${relationship_other} can be a select_one which is only relevant if ${id}>1

I hope this helps!

Best,
Andrea

You could use a join() calculation to accumulate all the relationship responses from your repeat group, eg

allrelationships = join(' ', ${relationship})

and then add a note containing your warning message, which has a relevance of

relevant = not(selected(${allrelationships}, 'Self'))

That way the note will only be shown if 'Self' was never selected. See selected() for details.

1 Like

Thanks for your reply! I tried doing this exactly as described and somehow it keeps showing up after every valid choice of not selecting Self in the repeat group, do you think I should try this using the indexed repeat?

It should work but make sure you specify the actual value (ie name) for the 'Self' option in the selected() statement, which may or may not be the same string as the option label which is displayed to the user.

Have a play around with this form, it should show a warning until you select the 'A' option:

warning.xls (5.5 KB)

Somehow this didn't seem to work for me even after trying different versions of the example form. Hence I tried something else and that seemed to work! I've attached the form, the form displays a warning "You have selected tracking baby wrongly" if "tracking baby" relation in the roster is not selected or has been selected thrice or more

warningform.xlsx (15.7 KB)