Using index-repeat and jr:choice for repeat group

What is the problem? Please be detailed.

What ODK tool and version are you using? And on what device and operating system version?

What steps can we take to reproduce the problem?

What you have you tried to fix the problem?

Anything else we should know or have? If you have a test form or screenshots or logs, attach here.

Dear,
I'm trying to count a name with jr:choice syntax within a repeat group where the name comes from a multiple answer question. And the choices of multiple answer questions comes from another repeat group with indexed-repeat syntax.

I can handle making choice of the name which comes from a repeat group with indexed-repeat syntax. And I can use the names as choice for a multiple answer question. But, when I'm trying to use the answers of the multiple answer question in another repeat group with jr:choice syntax, the form is not working. Such error is happening.

Error: b'ODK Validate Errors:\n>> XForm is invalid. See above for the errors.\norg.javarosa.xform.parse.XFormParseException: Invalid calculate for the bind attached to "${g1}.2${m_list}" : Bad node: org.javarosa.xpath.parser.ast.ASTNodeAbstractExpr@490d6c15 in expression selected-at( ${g1}.2/q10 , index()-)\n\nResult: Invalid'

It's not clear to me what you are trying to achieve. Could you attach your form as an example?

1 Like

yes, here is the from. In this form, I'm successful to place the response of first repeat group in choices and using them in another multiple response question. But, I'm trying to create another repeat group depending on the responses of the multiple response question.
Creating another repeat group depending on the answer is not the problem. The problem is happening when I'm trying to use the response of that multiple response question into the repeat group. I'm trying to use jr:choice syntax to do that. But that is not working.

test.xlsx (17.8 KB)

I'm' not sure If I understand everything but looks like you just need to change calculation in m_list (row 45) to selected-at(${q10}, position(..)-1)

Your form contains a few other bugs, for example I had to add missing choices but after fixing them I think you jsut need that small change.

Thank you @Grzesiek2010. Now, it's working. :slightly_smiling_face:

Hello @Grzesiek2010,
Sorry, I think I have a related problem and have tried everything but still keep getting the error message [Error evaluating field 'D3a_palm": the problem was located in calculate expression for....XPath evaluation: type mismatch for function 'jr:choice-name']

The problem is in Question D343 (or row 515). Uploading the XLS form is ok, but when I select more than one answers to D343, then the error message shows up and the form refuses to save. I've been trying to fix this for a few days now, so any help would be appreciated.gmlghana_v31.xlsx (304.1 KB)

The problem is that the same calculation formula (using position and jr:choice) works perfectly just a few rows above (in D318 and D331) and I can save the form without any problem. So I'm utterly confused...thanks so much in advance.

@Grzesiek2010
Following your advice to simplify the form on the other thread, I've simplified this one too (though have kept the previous two sections in case the problem stems from there). I would greatly appreciate your advice if possible! gmlghana_v32_test_repeat problem_sample.xlsx (98.1 KB)

I think I have a related problem to the above and have tried everything but still keep getting this error message: [Error evaluating field 'D3a_palm": the problem was located in calculate expression for....XPath evaluation: type mismatch for function 'jr:choice-name']

The problem is in Question D343. Uploading the XLS form is ok, but when I select more than one answers to question D343 and D546 (yellow highlighted), then the error message shows up and the form refuses to save. I've been trying to fix this for a few days now, so any help would be appreciated.

The mystery is that the same calculation formula (using position and jr:choice) works perfectly just a few rows above (in question D318 and D331 as well as D514 and D516, in red texts) and I can save the form without any problem. So I'm utterly confused...thanks so much in advance.