I have yet discovered another bug in the way CHT has implemented ‘enketo’.
When there is a negative number as output of a if clause in a calculate field, the form will not load and an error will be displayed.
I mean that something like this:
if(${var}>2,-1,0)
won’t work.
However,
if(${var}>2,+1,0)
will work.
I hope that those bugs get fixed when the new enketo version is shipped in an update.
@raf you are probably getting tired of me saying this , but yes, I have confirmed that this will be fixed with the Enketo upgrade we are shipping in cht-core 4.0.
For previous CHT versions, one workaround would be to use the int function to wrap the negative value: if(${var}>2,int(-1),0). That seems to bypass the error without changing the meaning of the logic…
Also just wanted to note for the record here (in case anyone reads this and gets confused later) the core issue here, I think, was how the Enketo xPath evaluator was converting values as part of its calculation. This issue must have been fixed in a later version of enketo-core and/or openrosa-xpath-evaluator that are being picked up in version 4.0 of the CHT. It was not exactly an issue with the way the CHT was using Enketo before…