Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

This page will help you to interpret some of the common error messages you find while trying to make builds of your application.

Click below to select an error that you are seeing.

Table of Contents
minLevel1
maxLevel6
outlinefalse
stylenone
typelist
printabletrue

Invalid XML in Form

You have written something invalid into one of your forms. 

...

In your form, the display or calculate logic in a question references itself.  This is normally caused by using a "." in the display logic or calculate logic for a question.  Please check the logic in the questions listed at the bottom of the error. 

Validation Error: For input string: "GPS"

The property /data/GPS is set to take default value 'GPS', but this is not a valid value for this question type. Remove the default value.

Case sharing for web users

When case sharing is turned on, it will often break when you attempt to preview a form because a web user cannot be in a case sharing group. The error message will look like:

"Logic references instance(groups)/groups/group/@id which is not a valid question or value"  

Common Repeat Group Error: Multiple Nodes Error

Overview

Often while using Repeat Groups (especially when multiple repeat groups are nested ), users face an issue which states something like this "Cannot convert multiple nodes to a raw value. Refine path expression to match only one node.". This document aims at trying to find the reason for such errors and how to resolve such issues in a repeat group.

Reason for Multiple nodes error

Before understanding the reason for the Multiple Nodes error in Repeat Group, you need to understand what a node means for a repeat group.

What is a Node?

In CommCare, almost everything is an XML structure behind the user interface. Any question you add on a form, any new form, and even an application has an xml structure behind it. An XML structure in any form can consist of a smaller XML structure which is called a node. In simplicity, a form consisting of questions basically means the form's xml node consists of different question nodes. Similarly, the cases in case-db of users are also stored in nodes of cases.

Node in case of Case-DB

The case-db node consists of nodes of cases. So when you use the statement instance('casedb')/casedb/case , you are telling CommCare to refer to all nodes of case-db. When you use instance('casedb')/casedb/case[@case_type = 'mother'][@status = 'open'], you are telling CommCare to refer to all the nodes of case-db whose case type is 'mother' and are still 'open' . Assuming that user has multiple cases of type 'mother' which are open, the output of this statement, instance('casedb')/casedb/case[@case_type = 'mother'][@status = 'open'], is always a set of nodes of cases (or this will result in Multiple Nodes)

Also, when you use instance('casedb')/casedb/case[@case_type = 'mother'][@status = 'open']/case_name, this will result in multiple nodes with just case_name

...

When you face the issue "Cannot convert multiple nodes to a raw value. Refine path expression to match only one node." in a repeat group, it means that in one of your question's calculations (or any configuration of the question) is expecting a single node but as per the logical statement you are using results in multiple nodes and CommCare is unable to resolve as to which node it should use do process your logical statement. For example, consider an application which registers a mother (case type : mother) and her children (case type : children) . Assuming that you have registered more than 2 mother cases and each mother case has 3 children cases created with a relation of parent-child between these two case types. There is a form which will now show the user the name of mother along with the list of children under each mother. For this, form uses a repeat group to iterate through the 'mother' case type nodes.

...

Now let's say you wanted to show the details first, before showing the details of the children of her children. For that you added a hidden variable type question to fetch the name of the mother whose case-id is currently in the loop. In that hidden variable's calculation, you added this calculation instance('casedb')/casedb/case[@case_type = 'mother'][@status = 'open']/case_name

...

Now , when you try to open the form, you will get the error "Cannot convert multiple nodes to a raw value. Refine path expression to match only one node" and the reason is clear that the calculation used for the hidden variable is resolving to a set of nodes of cases and not a single case as shown:

...

Resolution for Multiple nodes error

In this section, you will try to work on resolving the multiple nodes error which you saw in the last section.

Identification of erroneous calculation

First you need to identify the variable of the form which is throwing you the error.
If you see the error : "Calculation Error: Error in calculation for /data/mother_details/mother_iteration/item/mother_details_section/mother_name XPath nodeset has more than one node …… cannot convert multiple nodes to a raw value. Refine path expression to match only one node."

The highlighted text will guide you the exact location of variable where the error originates:

...

Fixing the error

Once the erroneous calculation is located, you need to fix the calculation involved. In the example you have seen, the calculation used for populating the name of mother is resolving into multiple nodes. Hence the error is thrown by the form. For fixing this particular error, you need to make sure that calculation results in a unique single node.
The expression used instance('casedb')/casedb/case[@case_type = 'mother'][@status = 'open']/case_name clearly doesn't have any conditioning to make sure it results in a unique node. In order to make this instance expression to yield a unique node, you will have to add a filtering condition on case-id . Since the current hidden variable is under a repeat group, the current index of the repeat group will be needed to fetch the current caseid . instance('casedb')/casedb/case[@case_type = 'mother'][@status = 'open'][@case_id =variable storing mother's case id]/case_nameFor the example used, this expression would be : instance('casedb')/casedb/case[@case_type = 'mother'][@status = 'open'][@case_id = #form/mother_details/mother_iteration/item/mother_id]/case_name
             Adding the highlighted filter on expression, you can make sure that the calculation only yields a unique node and the error of multiple nodes is not anymore.

Other Reasons

There could be multiple other reasons for Commcare throwing the multiple node error but the core of the reason remains the same i.e. somewhere some question calculation or a question which uses a calculation (which is further used in another question type like a label) is referring to a multiple node as a result of its calculation. In a couple of cases, this error also results from referring to a variable without using a correct reference to a question within a repeat group. If you use easy references with double-nested repeat groups the app can get confused pretty fast.

Troubleshooting

The first step in troubleshooting things like this is

  • Identify the question/calculation which is throwing the error.

  • Check for calculation conditions/display conditions/lookup-filters/default value of that question

  • If these calculations are based on an easy reference to another question, then it could be a possible issue. Usually removing any easy references and replacing them with relative paths to the question will fix the issue for you. Using easy reference is safe when a form is straight-forward and doesn't have complexities of nested repeat groups. But if the form has nested repeat groups, the safest bet is to use relative referencing in a repeat group.

  • Note: Most common source for this type of error is due to usage of easy reference in a lookup-table type question's filters OR a Calculation Condition involving reference to fixture data like locations or lookup-tables with filtering condition using easy referencing. 

Using current() expression with the correct referencing path is the safe way to avoid any multiple node error in repeat groups. The details of using current() expression is covered at https://dimagi.atlassian.net/wiki/x/pC7Kfw.

Common Repeat Group Error: Repeat bound to non-existent node

Overview

Sometimes while creating your app, you may decide that a Repeat Group that was using a fixed count now needs to use Model Iteration. When you try to look at the settings for your form or create a new version of your app, you see, Validation Error: Repeat bound to non-existent node.

Fixing the error

The fix for this error is as follows:

  • Create a new repeat group. It will need to have a different name from the original, but you will be able to update it at the end of the process.

  • Move everything from the original to that group. You can select multiple items at once and drag them under the new repeat group.

  • Copy the query for Model Iteration into the new group.

  • Delete the old group. At this point, there should be nothing under the group, as you will have moved everything to the new group.

  • Rename the new group. Once the old group is deleted, you can rename your new group (and its question id) to match the original.