Help!: Error with Form

I am testing a form to collect data from smallholder coffee farmers, and am getting an error message. The message says: “xpath evaluation type mismatch. This field is repeated:”
I have used the online form validator tool, and this does not detect any errors or problems with the form. Is anyone able to help me troubleshot this error please? I attach here the xls sheet used to construct the form.
Test Vietnam HH.xlsx (90.8 KB)

I tested your form with the online validator at ODK - XLSForm Online, and it showed an error due to missing labels in the repeat and group sections. However, when I tried to deploy the form on KoBoToolbox, no errors occurred.

1 Like

Thank you for sending an updated version with the labels. I used the online validator and there are now no prompts about missing labels. I have however re-tested the form in KoboCollect and am getting the exact same error message in the form at the exact same place. I attach here an image of the error. Clearly it is not to do with labelling. Any ideas on what is causing the problem?

Hi @danielh382 ,

This error occurred because you used a select_multiple question inside a repeat group but referenced it from outside the repeat group. The system cannot determine which repeat instance to index. To avoid this error, we can implement a workaround by adding a calculation question.

In this file, I added the following calculation within the repeat group:
if(selected(${other_crops_choices}, 'pepper'), 1, 0).

This calculation returns 1 if “pepper” is selected (indicating it is grown) and 0 if it is not.

Then, outside the repeat group, I used:
sum(${pepper_yn}) as pepper_flag, which holds the total count of “pepper” grown across all repeat instances.

Additionally, I used pepper_flag for a skip pattern.

In the attached file, I have highlighted the changes I made. The form has been tested and is now error-free.**

Let me know if you want any further refinements! :blush:
Test Vietnam HH (2).xlsx (92.1 KB)

1 Like

Thank you very much for your help with this, it is really appreciated. Unfortunately I am still getting the exact same error after these changes. The error only seems to happen if selecting multiple plots; for example, if answering “2” for the “How many separate coffee plots do you currently manage?” question (row 51 of the excel sheet), the error only happens when answering the question on row 139-148 for the second plot (it works fine for the first plot. Very strange!

@danielh382 Can you provide a screenshot to help identify the error?

I have already tested the KoBoCollect application on an Android phone. When the value is set to 2 for the question “How many separate coffee plots do you currently manage?”, I was able to proceed to the end without encountering any errors. I also successfully uploaded the data to the KoBoToolbox server.

1 Like

Sure, a screen shot is attached here. I’m using a Huawei tablet and the KoboCollect app (latest version) if that information helps?

Can you make sure

  1. redoply with the XLS file I provide and
  2. re-sync from kobo-collect application and make sure version update.
  3. Please don’t use old interview, start new interview with new version.

1 Like

I can confirm that I redeployed the survey with your latest xls, the version is fully up to date, and I started a new interview.

@danielh382

I have already tested it on my side. I tested it again, and no errors occurred.

Suggestions:

  1. Please upload it as a new project using the file I provided, named “Test Vietnam HH_NLS Fixed,” and test it with the KoBoCollect app.
  2. Try using a different Android device.

Test Vietnam HH_NLS Fixed V2.xlsx (91.3 KB)

1 Like

I am still getting the same error message. I’ve noticed that it only occurs if entering the same fruit trees for plot 2 as for plot 1; if entering different trees, the error message doesn’t occur. By entering different trees I was able to complete the form, however an error then occurred when I tried to send the finalised form to the server.

@danielh382

This error occurred for the same reason as the previous one. You used selected(${pepper_support_type}, 'living') in the skip pattern for the “pepper_support_seeds” group, referencing a multiple-response question inside a repeat group from outside.

I have fixed it by adding two calculation questions (highlighted in yellow). Please use this updated file.

If you encounter this type of error in the future, resolve it using two calculation questions, as I did.

Have a nice day! :blush:
Test Vietnam HH_NLS Fixed V3.xlsx (91.7 KB)

3 Likes

This now works perfectly - I can complete the form and send without any errors. Thank you so much for all your help with this. I would have never figured this out by myself, so your help is really appreciated!

2 Likes

@naylinsoe, :bowing_man: :tada: