I would like to use the xpath function jr:choice-name in a calculation to return the label of a selected answer--rather than the answer itself.
The item selected is from a "select_one_external species" filtered using a formula for the category in the choice_filter for that item.
I understand there is some trouble if it returns zero, so it is often nested in an if statement to check.
Would it be possible to calculate:
if(string-length(${species}) != 0,jr:choice-name(${species},'${species}'),'none observed')
I have tried inserting the above into the calculation as well as using:
calculate="if(string-length(${species}) != 0,jr:choice-name(${species},'${species}'),'none')"
I either get a blank for the whole calculation or the term "false"
My goal is to add the value of the label to a concatenation in the instance_name on the settings tab so that the instance includes the concatenated name of the observer, the date, and the species name (instead of the stored value of the unique species code) for quick review and sorting in the field.
My concatenation using this formula is working correctly:
concat(${observer}, "-",${species},"-",${date},"-",${time})