How to use unless on variable defined as:select options

Dear,

I tried to use the unless condition to hide the boolean when either variable C4, C5 or C6 is completed (Yes or No)
However when I run the code the boolean is Always hidden even if no selection is made on the variables c4, c5 or c6.

Could someone help me out?

Kind regards,

Glenn

{% unless c4 != 'Yes' or c4 != 'No' or c5 != 'Yes' or c5 != 'No' or c6 != 'Yes' or c6 != 'No' %}{% input custom.additional.duties as:boolean %}{% endunless %} **{% t "Additional duties diamond traders, repayment received tax credit for research and development and separate assessment on individual pension accruals" %}** {% if custom.additional.duties != 'false' %}

|-3%--|-62%-----------------------------------------------------------------------------------------------------------------------------------------------------------|:-10%--:|---:+
||{% t "The seperate assessment has not paid since no tax year 2013 existed" %}                                                                                       |{{1536}}|{% input c4 as:select options:"Yes|No" %}|
||{% t "The company has opted to spread the taxation during tax year 2013, however the second seperate assessment has not been paid since no tax year 2014 existed" %}|{{1537}}|{% input c5 as:select options:"Yes|No" size:'maxi'%}|
||{% t "The company has opted to spread the taxation during tax year 2013, however the second seperate assessment has not been paid since no tax year 2015 existed" %}|{{1538}}|{% input c6 as:select options:"Yes|No" %}|

Hello @GMOONS,

Did you try using if instead of unless? Since you are giving the option for both yes and no, maybe the unless statement is not a must.

Regards,
Mike

Hello @michail,

If I would use the if and make sure the boolean is hidden as soon as one of the variables is Yes or No:

Should I use the following code:

{% if c4 != empty and c5 != empty and c6 != empty %}
´´´
?

Kind regards,

Glenn

Hello @GMOONS,

Firstly, instead of empty, you should use blank but even then you will not have the results you need. If I understood correctly, what you want to do is to show nothing when one of your options has a value and when it has not value, to give you the option to check the boolean right?

The easiest and most simple way to do it is with an if statement like this one:

{% if c4 != blank or c5 != blank or c6 != blank %}{% else %}{% input custom.additional.duties as:boolean %}{% endif %}

So, when c4 or c5 or c6 are not blank, then it will show nothing, but if they have no value, it will let you check the boolean and make your selections.

Let me know if this works for you. If not, don’t hesitate to contact me again.

Regards,
Michail

Dear @michail,

It worked! Thanks!

Greetz

Glenn

1 Like