Need help: Dataset - validation rule for Yes/No value type

Hi, everyone,

I would like to create a validation rule for yes/no value-type of dataelement which should force the user to fill a number field if the answer is YES to a data element in a dataset". If the answer is No, then the user should not fill the number field.

I tried to use compulsory pair validation operator, but it is not working. I think I am using it incorrectly

I am wondering if anyone could help me with the expression.

Thanks

Hey @dmbantu,
As it explains in the documentation, " The Compulsory pair operator allows to require that data values must be entered for a form for both left and right sides of the expression, or for neither side. This means that you can require that if one field in a form is filled, then one or more other fields must also be filled." Home - DHIS2 Documentation

So maybe change it to a check mark for the yes without a no because what you have here in the compulsory pair is that it’s either both are null or both are non-null; therefore, if user presses yes they must fill out the other question but if they don’t press anything i.e. null then the other question can remain null. I hope this helps! (:

Hi @Gassim,

I have changed the DE to a check mark, but no validation error is displayed if I either press the check mark or enter a number in the second data element and click the complete button.
image

Thanks.

Hi @dmbantu, validation rules on boolean-type data elements are currently being worked on, see [DHIS2-10818] - Jira

1 Like

Hi @dhuser,

It is good to know that the DHIS 2 team is working on validation rules for Boolean type data elements.

Thanks