How to show field labels instead of codes to the user in a note?

Hello Community,

I am trying to show the ODK app user a summary of the answers they have selected as a note. However, I want to display the field labels instead of the names to the user.

Here is what I have attempted to do:

Type: calculate
Name: street_label
Calculation: jr:choice-name(${street_name}, '${street_label}')

Then in my note, I have the following label:

Street: ${street_label}

But the result is Street: undefined

What am I doing wrong?

Thanks!
Amy

Try this:

jr:choice-name(${street_name}, '${street_name}')

The first variable is the answer you want the label for, and the second variable is the list of choices containing the answer name and label. In your version, you've set it to search the list of choices from the street_label question - which won't return anything as it is a calculate type with no list of choices. See the docs for more info: https://docs.getodk.org/form-operators-functions/#jr-choice-name

4 Likes

Ciao @RippleNami and @danbjoseph,

When testing this out, I realized if jr:choice-name() is called on a select_multiple without selected-at() would also return Undefined as soon multiple options are selected.

In addition to @danbjoseph solution (for select_one type) and link to resources, you might also want to read more about use of selected-at which in conjunction with jr:choice-name retrieves a label of a select multiple at a specified index. This demo-form showcases both.

Cheers,
Jules R

2 Likes