I am trying to run an if statement in the calculation box of my xlsForm, it currently looks like this:
The second part of the calculation calls a function that finds the maximum value of previous results, and adds one, creating the next, new case number.
The second part of the calculation, starting from pulldata, has worked as I would expect it too, however when I look at the dashboard that is bringing in the survey, the values are overwritten to show the next highest case number.
I wrote the if statement in the same row in the XLSForm as the function as shown below.
I want the calculation to determine whether the field already has a value or not, if it does, I want to keep it, and if it does not, I would like to run the pulldata calculation.
The odd thing was that this exact calculation worked when I moved it to a different field.
The error it is giving me says,:
b'ODKValidate Errors:\n>>Something broke the parser. See above for a hint.\nDependencycycles amongst the xpath expressions in relevant/calculate\n\nResult: Invalid'
You cannot calc a field to itself since it causes a logic loop. It is a common ask but it cannot be done if you think about it.
Usually with these you create 3 fields. One for the number, one for pulldata, and the 3rd to pick the correct value to send to the service. You can set the first to to bind null so that they are not in the service if you like.
Hope that helps and makes sense.