Choice-name() not working when list options loaded from csv

Hi all,

I am having problems using choice-name() within a repeat-group when data
has been loaded from a csv:

First I load data from a csv to populate a multi-select.
Once selections have been made I have a repeat-group which repeats for each
selection (e.g. 3 items selected = 3 repeats)
Each repeat needs to display the corresponding name and label that was
selected, in order to request further info on each.

For the name I use selected-at() and this works.
selected-at(${catch_specie},position(..)-1)

For the label I use choice-name():
jr:choice-name(selected-at(${catch_specie},position(..)-1),
'${catch_specie}')
This gives a blank result.
It does work correctly when my multi-select options are listed under the choices
tab (I use XLSForm), instead of being loaded from .csv file.

Files showing both are attached.

Does anyone know why this is happening? Is it a bug, or expected behaviour?

I would appreciate any suggestions for a workaround.

Thanks!
Andrew

test.zip (21.3 KB)

It is likely a bug. I've created an issue for this:
https://code.google.com/p/opendatakit/issues/detail?id=1153

It is unlikely the core team will investigate this in the near future.

··· On Thu, Jun 18, 2015 at 8:46 AM, Andrew wrote:

Hi all,

I am having problems using choice-name() within a repeat-group when data
has been loaded from a csv:

First I load data from a csv to populate a multi-select.
Once selections have been made I have a repeat-group which repeats for
each selection (e.g. 3 items selected = 3 repeats)
Each repeat needs to display the corresponding name and label that was
selected, in order to request further info on each.

For the name I use selected-at() and this works.
selected-at(${catch_specie},position(..)-1)

For the label I use choice-name():
jr:choice-name(selected-at(${catch_specie},position(..)-1),
'${catch_specie}')
This gives a blank result.
It does work correctly when my multi-select options are listed under the choices
tab (I use XLSForm), instead of being loaded from .csv file.

Files showing both are attached.

Does anyone know why this is happening? Is it a bug, or expected behaviour?

I would appreciate any suggestions for a workaround.

Thanks!
Andrew

--

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/d/optout.

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

Thanks Mitch, noted.

For anyone else bumping into this, the workaround I've used is to make use
of pulldata() to get the value from the same file as the search():

calculate sel_field
selected-at(${catch_specie},position(..)-1)
calculate sel_label
pulldata('Species_Wcoast','name_Eng','name_key',${sel_field})

A further workaround is needed if you are dealing with multiple languages:

  1. First you need to determine the language in use by the form. This is not
    accessible within a variable, so you need to calculate it.
    For this you look at the selected value of a multichoice question
    (select_one or select_multiple) which does NOT load its options from a csv
    file, so that you can still use jr:choice-name() .This can be used to test
    which language label was displayed for the choice.
    In my case I used a yes/no question - in English the labels are "Yes" and
    "No", in Afrikaans "Ja" and "Nee". So if "Yes" or "No" was selected, then
    I know the form is being displayed in English, and I must pulldata() from
    the English label column

calculate yesno_label jr:choice-name(selected-at(${permit},0),
'${permit}')
calculate form_language if(${yesno_label}='Yes' or
${yesno_label}='No' ,'English','Afrikaans')

  1. Second, you use the same pull_data as above, but select the correct
    language label column depending on the calculated language:

calculate sel_field
selected-at(${catch_specie},position(..)-1)
calculate sel_label if(${form_language}='English',
pulldata('Species_Wcoast','name_Eng','name_key',${sel_field}),
pulldata('Species_Wcoast','name_Afr','name_key',${sel_field}))

Hope that helps someone else!

Regards,
Andrew

··· On Monday, 29 June 2015 21:33:55 UTC+2, Mitch Sundt wrote: > > It is likely a bug. I've created an issue for this: > https://code.google.com/p/opendatakit/issues/detail?id=1153 > > It is unlikely the core team will investigate this in the near future. > > > On Thu, Jun 18, 2015 at 8:46 AM, Andrew <acawo...@gmail.com > wrote: > >> Hi all, >> >> I am having problems using choice-name() within a repeat-group when data >> has been loaded from a csv: >> >> First I load data from a csv to populate a multi-select. >> Once selections have been made I have a repeat-group which repeats for >> each selection (e.g. 3 items selected = 3 repeats) >> Each repeat needs to display the corresponding name and label that was >> selected, in order to request further info on each. >> >> For the name I use selected-at() and this works. >> selected-at(${catch_specie},position(..)-1) >> >> For the label I use choice-name(): >> jr:choice-name(selected-at(${catch_specie},position(..)-1), >> '${catch_specie}') >> This gives a blank result. >> It does work correctly when my multi-select options are listed under the choices >> tab (I use XLSForm), instead of being loaded from .csv file. >> >> Files showing both are attached. >> >> Does anyone know why this is happening? Is it a bug, or expected >> behaviour? >> >> I would appreciate any suggestions for a workaround. >> >> Thanks! >> Andrew >> >> -- >> -- >> Post: opend...@googlegroups.com >> Unsubscribe: opendatakit...@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...@googlegroups.com . >> For more options, visit https://groups.google.com/d/optout. >> > > > > -- > Mitch Sundt > Software Engineer > University of Washington > mitche...@gmail.com >