Migrating from ODK based platforms, I have realized that some calculations are differently handled in CHT.
For instance an empty integer is evaluated to zero.
If I have an integer, say height, and have a calculation later on that checks for instance if a child is smaller than a threshold:
${height}<90
This is evaluated to TRUE.
In ODK it would be FALSE because ${height} is empty. See also here in ODK docs
CHT equals an empty integer with 0
Could you point me to a reference, documentation where those differences are mentioned so I can adapt my XLS forms?
Generally speaking, I think the goal is for CHT to properly implement the ODK spec with no surprising differences to the base functionality. The CHT adds some additional functionality that can be leveraged by forms (documented here), but I do not know of any behavior differences from the basic ODK functionality that are intentionally included in the CHT.
Dear @jkuester,
Thank you for helping me out. While waiting for this to be fixed, I have applied this workaround. It might be useful to someone else.
as ${height} < 90 evaluates to true if height is empty, one must write
Dear @jkuester,
as you told me that CHT is supposed to implement ODK specs 1:1 (and then building on top of it), let me mention another discrepancy that I have detected:
CHT fails to execute calculations that start with a negative number.
For instance, if we have a variable var1and we have a calculate field with the following formula: -5 * ${var1} + 20, then it will not be executed, and the form does not load.
@raf this seems related to this issue which is fixed in openrosa-xpath-evaluator v2. CHT is currently on the 1.x release but should be upgraded once this lands.