Community Health Toolkit

Displaying selected options from multi-select as a separate list

I have the following multi-select question:
select_multiple delivery_complications

I want to create a list right below this which displays the options selected by user. Can someone share a snippet of how that’s done?

Here’s what I have tried:
I created a note data type and referenced the multi-select label with a choice-filter like this:

contains(${delivery_complications}, name) or name = 'none'

Here’s the complete variable:

note delivery_complications_risk ${delivery_complications} ${delivery_complications}

However, this gives me a space delimited list of names and not labels. How can I get an end line delimited list of labels?

Referencing a select_* variable gives the values and not the labels. You would have to use jr:choice-name(${variable}, 'value') for each of the values you’d want to retrieve the correct choice label.

E.g

if(selected(${delivery_complications}, 'xyz'), jr:choice-name(${delivery_complications}, 'xyz') would give the choice label associated with value ‘xyz’.

Here’s a link to the odk spec on jr:choice-name

1 Like