REQUIRED for groups not working (Enketo)

Dear all,

For some inexplicable reason the required field for my groups is no longer working. I have a simple require condition for each of my groups

selected(${consent_check},‘yes’)

Yet, even though the answer to the question ${consent_check} is ‘yes’, the groups are not appearing. What’s even more bizzare, is that when I run the exact same xls form through ODK validate (ODK - XLSForm Online) the form works correctly! It’s only not functioning through the kobo platform.

So I appear to have isolated the problem.

In one group, I had used nested parentheses in the required field and that seems to break everything.

For example:

selected(${consent_check},‘yes’) and (selected(${unit_level},‘individual’) or selected(${unit_level},‘household’))

The reason I had used nested parentheses is that, without them, I’m not certain that the groups would trigger correctly without them. In the above example, what I want is for the group to trigger when consent is given and the unit level is EITHER individual or household. Without parentheses, the group triggers without consent if only the last condition, unit_level=‘household’, is true.

It’s odd that the nested parenthesis works in ODK validate, and even more odd that using nested parenthesis appears to prevent other groups from triggering, even if the syntax for latter groups doesn’t use nested parentheses.

Is this a bug that can be fixed?

Hello,
would you mind to try two other syntax versions:

  • Put the whole in an additional ( … ).
  • Put the first condition, i.e. before the and, in an additional bracket.

It might be a bug, the core team may say more.
You need your brackets as cannot be combined directly with or.

Hi wroos,

Thanks for your suggestion. Unfortunately it doesn’t work.

I cannot fathom this problem. In fact, it doesn’t appear to be parentheses at all now, so my earlier conclusion was incorrect.

For some reason, after a certain point in the form, if there is any syntax in the required field for a group then the group does not show.

The first handful of groups work fine, but at group 7, it doesn’t work. Even if the syntax in that group is exactly the same as in prior groups–e.g. “selected(${consent_check},‘yes’)”

I can confirm that my form still works as expected using ODK - XLSForm Online v2.x

I ended up rebuilding the entire survey row by row.

The issue was a lone calculate field. It was an “if” statement that was incorrect. For whatever reason, this caused the issue with the groups and relevants.

So, now people know… if you make a mistake in a calculate field, this can be an outcome!

1 Like

Thank you @sjed1 for sharing your solution to the entire community and making the community a learning and sharing platform. Expecting the same in the upcoming days too.

Hello,
Thanks! Would you mind to add a few details?

  • The wrong syntax of this if.
  • The position of this if towards the group 7.

Maybe you could even provide an extract of your form structure here?

Possibly related:

2 Likes

Hi Wroos,

Unfortunately I didn’t save a version of the XLS with the offending syntax. I do recall that it was a fairly complex nested IF statement, For whatever reason I made an error that wasn’t picked up by the validation but still broke the survey.