Error in implementation of enketto

Dear all,

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:


won’t work.


will work.

I hope that those bugs get fixed when the new enketo version is shipped in an update.

Best regards


@raf you are probably getting tired of me saying this :smile:, 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…

Hehe, yes I can’t wait for you to roll this out. Thank you.

1 Like

In case this is interesting for someone else:
I could not use your solution because my numbers were floats, but this


is working as well.

Nice! Thanks for posting the solution!

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…