Formhub - Displaying selected label from select_one list

Kindly asking assistance on how to display the selected item's "label"
rather than the "name" from select_one list.

Thanks in advance
JDChinga

JDChinga,

Here's the relevant clip from the SurveyCTO documentation:

jr:choice-name(value, 'field'): Returns the label for a select_one or
select_multiple field choice (as in the calculate expression
"jr:choice-name(${selectonefield}, '${selectonefield}')" to return the
label for the currently-selected choice in the selectonefield field). For
select_multiple fields, you can combine with selected-at() to get the label
for individual selections (as in
"jr:choice-name(selected-at(${selectmultfield}, 0), '${selectmultfield}')"
to return the label for the first choice in the selectmultfield field).

I expect that the same function call should work from formhub.

Best,

Chris

··· On Fri, Sep 20, 2013 at 6:45 AM, Jeffrey Dirawo wrote:

Kindly asking assistance on how to display the selected item's "label"
rather than the "name" from select_one list.

Thanks in advance
JDChinga

--

Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en


You received this message because you are subscribed to the Google Groups
"ODK Community" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to opendatakit+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Don't seem to get choice-name(value, 'field') to work in Formhub. I have
attached a sample XLS file.
Thanks.

sample.xlsx (189 KB)

··· On Fri, Sep 20, 2013 at 12:45 PM, Jeffrey Dirawo wrote:

Kindly asking assistance on how to display the selected item's "label"
rather than the "name" from select_one list.

Thanks in advance
JDChinga

Jeffrey,

The jr: on the front is quite important. Did you try jr:choice-name()?

Best,

Chris

··· On Sep 24, 2013 12:00 PM, "Jeffrey Dirawo" wrote:

Don't seem to get choice-name(value, 'field') to work in Formhub. I
have attached a sample XLS file.
Thanks.

On Fri, Sep 20, 2013 at 12:45 PM, Jeffrey Dirawo jdchinga@gmail.comwrote:

Kindly asking assistance on how to display the selected item's "label"
rather than the "name" from select_one list.

Thanks in advance
JDChinga

--

Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en


You received this message because you are subscribed to the Google Groups
"ODK Community" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to opendatakit+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

I encountered this error on attempting to display the form:

A formula evaluation error occurred. Please contact
support@formhub.org<support@formhub.org?subject=xpath%20errors%20for:%20https://i5h3h.enketo.formhub.org/webform&body=Error%20occurred%20trying%20to%20evaluate:%20jr:choice-name%28%20/sample/site%20,%20%27%20/sample/site%20%27%29,%20message:%20d%20is%20null>with
this error:

  • Error occurred trying to evaluate: jr:choice-name( /sample/site , '
    /sample/site '), message: d is null

I appreciate your assistance.

··· On Tue, Sep 24, 2013 at 12:23 PM, Jeffrey Dirawo wrote:

Don't seem to get choice-name(value, 'field') to work in Formhub. I
have attached a sample XLS file.
Thanks.

On Fri, Sep 20, 2013 at 12:45 PM, Jeffrey Dirawo jdchinga@gmail.comwrote:

Kindly asking assistance on how to display the selected item's "label"
rather than the "name" from select_one list.

Thanks in advance
JDChinga

Apparently, jr:choice-name cannot tolerate a blank value for its first
argument. This is causing the error.

To work around this, define the calculate expression to be:

if(string-length(${site}) !=
0,jr:choice-name(${site},'${site}'),'(unspecified location)')

This tests to ensure that a site has been selected ( the ${site} value is
not a zero-length string ) and uses jr:choice-name only if that is the
case. Otherwise, it returns the string '(unspecified location)'

Note that the first argument to jr:choice-name should not be quoted -- you
want the selected value, and will use that to look up the name for that
value in the choice list.

Mitch

··· On Tue, Sep 24, 2013 at 11:52 AM, Jeffrey Dirawo wrote:

I encountered this error on attempting to display the form:

A formula evaluation error occurred. Please contact support@formhub.org<support@formhub.org?subject=xpath%20errors%20for:%20https://i5h3h.enketo.formhub.org/webform&body=Error%20occurred%20trying%20to%20evaluate:%20jr:choice-name%28%20/sample/site%20,%20%27%20/sample/site%20%27%29,%20message:%20d%20is%20null>with this error:

  • Error occurred trying to evaluate: jr:choice-name( /sample/site , '
    /sample/site '), message: d is null

I appreciate your assistance.

On Tue, Sep 24, 2013 at 12:23 PM, Jeffrey Dirawo jdchinga@gmail.comwrote:

Don't seem to get choice-name(value, 'field') to work in Formhub. I
have attached a sample XLS file.
Thanks.

On Fri, Sep 20, 2013 at 12:45 PM, Jeffrey Dirawo jdchinga@gmail.comwrote:

Kindly asking assistance on how to display the selected item's "label"
rather than the "name" from select_one list.

Thanks in advance
JDChinga

--

Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en


You received this message because you are subscribed to the Google Groups
"ODK Community" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to opendatakit+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
Mitch Sundt
Software Engineer
University of Washington
mitchellsundt@gmail.com

Many thanks Mitch - it's working perfect.
Jeffrey