Ifi does'nt work in fori

I want to use an ifi to hide a part of our letter if no data is in the fori. The fori works fine, but when I export the letter to pdf, the part with the data I input is never visible.

image

image

How do I have to implement the ifi to work with the fori in the table?

{% ifi VAA.Soort != blank %}
Volgende voordelen betreffende het privégebruik van bepaalde bedrijfsgoederen of –kosten werden reeds aangeven aan de fiscus:

{% stripnewlines %}
| Aard voordeel
| Bedrag
{% newline %}
|:----30%----
|-----30%—:
{% newline %}
{% fori VAA in company.custom.voordeel %}
| {% input VAA.Soort %}
| {% input VAA.Bedrag as:currency %}{% newline %}
{% endfori %}
{% endstripnewlines %}
{% endifi %}

Hi @VVAcc,

So in general the use of the ifi-statement is the correct way to approach this. The only issue is the content of the ifi-statement. Currently you are trying to check if a variable with namespace VAA and key Soort is blank. However, this variable does not exist. What does exist is company.custom.voordeel.voordel_1.Soort as part of the fori-loop.

So in order to check if data is included in the column VAA.Soort you should access the fori-loop separately at the top of your code and check if there is data in the column VAA.Soort for any of the rows.

To achieve this, you could add something like this:

{% assign show_table = false %}
{% for VAA in company.custom.voordeel %}
{% if VAA.Soort != blank %}{% assign show_table = true %}{% endif %}
{% endfor %}

And check this show_table variable in the ifi-statement.

{% ifi show_table != blank %}

If you only want to hide the table when the fori is completely empty (so not only checking the first column) you could also easily do

{% ifi company.custom.voordeel != empty %}

One final remark, is there a specific reason you would link this fori-loop to the company drop? By doing so, the input fields will not be period specific. Meaning if you add or remove one line in one period, it will also be added or removed in other periods.

Hope this helps!

Kind regards,
Robin

Hi Robin,

I adjusted as follow and it works fine!

{% assign show_table = false %}
{% for VAA in period.custom.voordeel %}
{% if VAA.Soort != blank %}{% assign show_table = true %}{% endif %}
{% endfor %}
{% ifi period.custom.voordeel != empty %}
{% stripnewlines %}
| Aard voordeel
| Bedrag
{% newline %}
|:----30%----
|-----30%—:
{% newline %}
{% fori VAA in period.custom.voordeel %}
| {% input VAA.Soort %}
| {% input VAA.Bedrag as:currency %}{% newline %}
{% endfori %}
{% endstripnewlines %}
{% endifi %}

I used ‘company’ because the type of VAA will be the same every period. But because the amount will change I corrected it to ‘period’.

Thx for the help

Hi @VVAcc,

If this code is used for a reconciliation or account template, adding period. is not even necessary. Every custom is automatically linked to period.

Happy I could help! Good luck with the rest of the template :+1:

Kind regards,
Robin