# If statement causes includes to stop working

**URL:** <https://community.silverfin.com/t/if-statement-causes-includes-to-stop-working/1589>\
**Category:** Templates\
**Created:** [October 21, 2019, 1:25pm UTC](https://community.silverfin.com/t/if-statement-causes-includes-to-stop-working/1589 "2019-10-21T13:25:29Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![ronald\_groot\_RSF](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.silverfin.com/ronald_groot_rsf/32/1019_2.png) [@ronald\_groot\_RSF](https://community.silverfin.com/u/ronald_groot_RSF)\
**Post date:** [October 21, 2019, 1:25pm UTC](https://community.silverfin.com/t/if-statement-causes-includes-to-stop-working/1589/1 "2019-10-21T13:25:29Z")

</div>

I’m trying to block certain content for external users by using this code:

```auto
{% comment %}For internal use only{% endcomment %}
{% if user.email contains "finance.com" and user.email contains "rs" %}

```

I got this working, but there’s two things that are bothering me:

1. I would like to include the ‘@’ symbol, but then the check fails. Is there any way I can add this?
2. There’s a nasty side effect when I place this if statement above my includes like this:

```auto
{% comment %}For internal use only{% endcomment %}
{% if user.email contains "finance.com" and user.email contains "rs" %}

{% comment %}Get checks, selects and tables{% endcomment %}
{% include "parts/defaults" %}
{% include "parts/assigns" %}
{% include "parts/setvars" %}

```

In my include ‘setvars’ I’m setting reconciliation on the template using this code:

```auto
{% comment %}Set variables on answers to questions below{% endcomment %}
{% if custom.opdrachtbevestiging.value != "Ja" %}{% assign check_opdracht = check_opdracht+1 %}{% unreconciled 1 %}{% endif %}
{% if period.custom.admin.uren == 0 %}{% assign check_opdracht = check_opdracht+1 %}{% unreconciled 1 %}{% endif %}
{% if period.custom.control.uren == 0 %}{% assign check_opdracht = check_opdracht+1 %}{% unreconciled 1 %}{% endif %}
{% if custom.fee.value != "Ja" and custom.fixed_fee.Verklaring == blank %}{% assign check_opdracht = check_opdracht+1 %}{% unreconciled 1 %}{% unreconciled 1 %}{% endif %}
{% if company.custom.team.value == blank %}{% assign check_opdracht = check_opdracht+1 %}{% unreconciled 1 %}{% endif %}
{% if company.custom.relatiebeheerder.value == blank %}{% assign check_opdracht = check_opdracht+1 %}{% unreconciled 1 %}{% endif %}

```

Problem is, my template reconciles, no matter what the custom values are that are used in the if statement. Am I missing something?

---

<div class="post-metadata">

**Author:** ![sven](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.silverfin.com/sven/32/1495_2.png) [@sven](https://community.silverfin.com/u/sven)\
**Post date:** [October 21, 2019, 1:52pm UTC](https://community.silverfin.com/t/if-statement-causes-includes-to-stop-working/1589/2 "2019-10-21T13:52:46Z")

</div>

Hi @ronald_groot_RSF,

Perhaps the “@” is causing issues in the bckground, but what you could do, is replace it by something else.

For example:

{% assign user\_mail = user.email | replace:"@",“ **at** \_” %}

and use that variable in your if-statement. I’ll check later on onto why that “@” is not working properly.

For the reconciled status, that’s hard to check for me, without all other code. What i would do, is add this in your code, so you know if the IF-statements are executed or not, and which one:

```auto
{% comment %}Set variables on answers to questions below{% endcomment %}
{% if custom.opdrachtbevestiging.value != "Ja" %}
  Test custom.opdrachtbevestiging.value 
  {% assign check_opdracht = check_opdracht+1 %}{% unreconciled 1 %}
{% endif %}
{% if period.custom.admin.uren == 0 %}
  Test period.custom.admin.uren
  {% assign check_opdracht = check_opdracht+1 %}{% unreconciled 1 %}
{% endif %}
{% if period.custom.control.uren == 0 %}
  Test period.custom.control.uren
{% assign check_opdracht = check_opdracht+1 %}{% unreconciled 1 %}
{% endif %}
{% if custom.fee.value != "Ja" and custom.fixed_fee.Verklaring == blank %}
  test custom.fee.value != "Ja" and custom.fixed_fee.Verklaring
  {% assign check_opdracht = check_opdracht+1 %}{% unreconciled 1 %}{% unreconciled 1 %}
{% endif %}
{% if company.custom.team.value == blank %}
  test company.custom.team.value
  {% assign check_opdracht = check_opdracht+1 %}{% unreconciled 1 %}
{% endif %}
{% if company.custom.relatiebeheerder.value == blank %}
  test company.custom.relatiebeheerder.value
  {% assign check_opdracht = check_opdracht+1 %}{% unreconciled 1 %}
{% endif %}

```

If nothing is seen from above code, then it’s correct that the template becomes reconciled, and something has to be tweaked in the code.

Hope that helps? Keep us posted 😊

---

<div class="post-metadata">

**Author:** ![ronald\_groot\_RSF](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.silverfin.com/ronald_groot_rsf/32/1019_2.png) [@ronald\_groot\_RSF](https://community.silverfin.com/u/ronald_groot_RSF)\
**Post date:** [October 21, 2019, 2:45pm UTC](https://community.silverfin.com/t/if-statement-causes-includes-to-stop-working/1589/3 "2019-10-21T14:45:14Z")

</div>

I’ve tested the code and the include is loaded:

```auto
{% comment %}Set variables on answers to questions below{% endcomment %}
Test {{ custom.opdrachtbevestiging.value }}
{% if custom.opdrachtbevestiging.value != "Ja" %}{% assign check_opdracht = check_opdracht+1 %}{% unreconciled 1 %}{% endif %}

```

Gives me the ‘Test Nee’ value back, but the result is the same, the template stays reconciled.

---

<div class="post-metadata">

**Author:** ![sven](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.silverfin.com/sven/32/1495_2.png) [@sven](https://community.silverfin.com/u/sven)\
**Post date:** [October 21, 2019, 2:49pm UTC](https://community.silverfin.com/t/if-statement-causes-includes-to-stop-working/1589/4 "2019-10-21T14:49:09Z")

</div>

Is the code with all the unreconciled tags by any chance been set between ic-tags?

And by the way, the “Test” needs to be put within the if-statement (my bad, as I was wrong).

```auto
{% comment %}Set variables on answers to questions below{% endcomment %}

{% if custom.opdrachtbevestiging.value != "Ja" %}
Test {{ custom.opdrachtbevestiging.value }}
{% assign check_opdracht = check_opdracht+1 %}{% unreconciled 1 %}
{% endif %} 

```

Is it then still showing?

---

<div class="post-metadata">

**Author:** ![ronald\_groot\_RSF](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.silverfin.com/ronald_groot_rsf/32/1019_2.png) [@ronald\_groot\_RSF](https://community.silverfin.com/u/ronald_groot_RSF)\
**Post date:** [October 22, 2019, 7:06am UTC](https://community.silverfin.com/t/if-statement-causes-includes-to-stop-working/1589/5 "2019-10-22T07:06:33Z")

</div>

So here’s the code now:

```auto
{% comment %}Set variables on answers to questions below{% endcomment %}
{{ custom.opdrachtbevestiging.value }}
{% if custom.opdrachtbevestiging.value != "Ja" %}True{% assign check_opdracht = check_opdracht+1 %}{% unreconciled 1 %}{% else %}False{% endif %}
{% if period.custom.admin.uren == 0 %}{% assign check_opdracht = check_opdracht+1 %}{% unreconciled 1 %}{% endif %}
{% if period.custom.control.uren == 0 %}{% assign check_opdracht = check_opdracht+1 %}{% unreconciled 1 %}{% endif %}
{% if custom.fee.value != "Ja" and custom.fixed_fee.Verklaring == blank %}{% assign check_opdracht = check_opdracht+1 %}{% unreconciled 1 %}{% unreconciled 1 %}{% endif %}
{% if company.custom.team.value == blank %}{% assign check_opdracht = check_opdracht+1 %}{% unreconciled 1 %}{% endif %}
{% if company.custom.relatiebeheerder.value == blank %}{% assign check_opdracht = check_opdracht+1 %}{% unreconciled 1 %}{% endif %}

```

This results in:

Nee  
True

So the include has the correct value (Nee) and shows the correct outcome of the if-statement (True).

But still the unreconciled in not triggered. Once again, all of this code works when (in my main code) I change this:

```auto
{% comment %}For internal use only{% endcomment %}
{% if user.email contains "finance.com" and user.email contains "rs" %}

{% comment %}Get checks, selects and tables{% endcomment %}
{% include "parts/defaults" %}
{% include "parts/assigns" %}
{% include "parts/setvars" %}

```

To this:

```auto
{% comment %}Get checks, selects and tables{% endcomment %}
{% include "parts/defaults" %}
{% include "parts/assigns" %}
{% include "parts/setvars" %}

{% comment %}For internal use only{% endcomment %}
{% if user.email contains "finance.com" and user.email contains "rs" %}

```

---

<div class="post-metadata">

**Author:** ![sven](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.silverfin.com/sven/32/1495_2.png) [@sven](https://community.silverfin.com/u/sven)\
**Post date:** [October 22, 2019, 7:19am UTC](https://community.silverfin.com/t/if-statement-causes-includes-to-stop-working/1589/6 "2019-10-22T07:19:53Z")

</div>

Hi @ronald_groot_RSF,

Your `parts/setvars` will only be executed when the if-statement is true, meaning that only in that situation your template can become unreconciled.

If the statement is not true however, your template will be automatically set on reconciled if the type of reconciliation is set on this:  
 ![49](https://canada1.discourse-cdn.com/flex030/uploads/getsilverfin/original/2X/a/a1bc306e0d69b68a7321dff6b8d6b4b0559883ba.png)

When it would be set on `Reconciliation necessary, and invalid without data`, then the recon would stay unreconciled unless someone would enter a value somewhere.

By the way, I would recommend leaving the unreconciled out of the if-statement. Unless I’m misunderstanding the issue, I don’t think reconciling should be user-specific.

Thanks for the detailled answer by the way

---

<div class="post-metadata">

**Author:** ![ronald\_groot\_RSF](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.silverfin.com/ronald_groot_rsf/32/1019_2.png) [@ronald\_groot\_RSF](https://community.silverfin.com/u/ronald_groot_RSF)\
**Post date:** [October 22, 2019, 7:37am UTC](https://community.silverfin.com/t/if-statement-causes-includes-to-stop-working/1589/7 "2019-10-22T07:37:31Z")

</div>

Hi @sven,

Yes, you are correct, but the issue is this. The unreconclied is now basically in a nested if statement and both if statements are true. If I take the include out of the equation it would look like this, correct?

```auto
{% comment %}For internal use only{% endcomment %}
{% if user.email contains "finance.com" and user.email contains "rs" %}
{% if custom.opdrachtbevestiging.value != "Ja" %}
True{% assign check_opdracht = check_opdracht+1 %}{% unreconciled 1 %}
{% else %}
False
{% endif %}
{% endif %}

```

The second if statement gives me the desired result (True, and the assign is fired), but the unreconciled is not handled. This seems unconnected to the reconciliation type, as The unreconnciled is triggered if I take it out of the first if statement.

Reconciling is actually user specific. An external user does not need to do anything with the template, so it is okay for an external user to see the template as reconciled.

As I’m typing this: could that be the actual issue? Is what I want even possible? Because the reconciliation would give the same result for all users, right? Is the template itself reconciled by a system user? That would explain the issue…

---

<div class="post-metadata">

**Author:** ![sven](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.silverfin.com/sven/32/1495_2.png) [@sven](https://community.silverfin.com/u/sven)\
**Post date:** [October 22, 2019, 7:53am UTC](https://community.silverfin.com/t/if-statement-causes-includes-to-stop-working/1589/8 "2019-10-22T07:53:07Z")

</div>

I’m having the same feeling, but I’ll need to dig deeper to be sure. I can simulate it now, where my recon is reconciled while I see an indicator in my template, so that is not what should be happening.

I’ll keep you informed.

By the way: any user should be able to see whether or not the recon is reconciled, no?  
I agree on the content being hidden from certain users, but the reconciliation itself is a use-case I haven’t heard yet 🙂

---

<div class="post-metadata">

**Author:** ![ronald\_groot\_RSF](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.silverfin.com/ronald_groot_rsf/32/1019_2.png) [@ronald\_groot\_RSF](https://community.silverfin.com/u/ronald_groot_RSF)\
**Post date:** [October 22, 2019, 8:30am UTC](https://community.silverfin.com/t/if-statement-causes-includes-to-stop-working/1589/9 "2019-10-22T08:30:43Z")

</div>

Ideally I would be able to control it. So external users see the template as reconciled (as they do not have to do anything themselves), while internal users see the reconciliation based on the actual code.

I could work around the issue, but I’d just rather not…

---

<div class="post-metadata">

**Author:** ![ronald\_groot\_RSF](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.silverfin.com/ronald_groot_rsf/32/1019_2.png) [@ronald\_groot\_RSF](https://community.silverfin.com/u/ronald_groot_RSF)\
**Post date:** [October 22, 2019, 8:31am UTC](https://community.silverfin.com/t/if-statement-causes-includes-to-stop-working/1589/10 "2019-10-22T08:31:32Z")

</div>

Oh and thanks for your help so far @sven 😃

---

<div class="post-metadata">

**Author:** ![sven](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.silverfin.com/sven/32/1495_2.png) [@sven](https://community.silverfin.com/u/sven)\
**Post date:** [October 22, 2019, 11:36am UTC](https://community.silverfin.com/t/if-statement-causes-includes-to-stop-working/1589/11 "2019-10-22T11:36:39Z")

</div>

No problem @ronald_groot_RSF.

I already have some feedback, and I’m afraid it’ll debunk the case.

Reconciliation cannot be user specific; it needs to be the same for everyone. We rely on this fact for performance as well which is why we cache the result.

If it would be user specific we couldn’t cache it plus the workflow completion calculations would be done per user and we wouldn’t be able to cache those either which would pretty much lock the platform.

So the way we do it is that we simply don’t pass user drop when calculation reconciled state for ledger. As a consequence `unreconciled` inside a if block that checks anything on an user will simply be false/ignored.

So I hope this helps you understand why we do this.

Is it an option for you to just hide parts of the template for specific users, and leave the reconciliation for everyone?  
As you can see, I’m having a hard time to see the benefit on why hiding a reconciliation from anyone 🙃  
Feel free to fill me in on this @ronald_groot_RSF

---

<div class="post-metadata">

**Author:** ![ronald\_groot\_RSF](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.silverfin.com/ronald_groot_rsf/32/1019_2.png) [@ronald\_groot\_RSF](https://community.silverfin.com/u/ronald_groot_RSF)\
**Post date:** [October 22, 2019, 12:17pm UTC](https://community.silverfin.com/t/if-statement-causes-includes-to-stop-working/1589/12 "2019-10-22T12:17:38Z")

</div>

Okay, thanks. I kind off figured it would be that. Makes total sense as well. It’s not that I want to hide the reconciliation, it’s just that I thought it would be easiest to just not show it to prevent questions.

But this is totally fine. Like I said, I already have a workaround in place (by simply not including the setting of the reconciliation within the user if-statement.

---

<div class="post-metadata">

**Author:** ![sven](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.silverfin.com/sven/32/1495_2.png) [@sven](https://community.silverfin.com/u/sven)\
**Post date:** [October 22, 2019, 12:22pm UTC](https://community.silverfin.com/t/if-statement-causes-includes-to-stop-working/1589/13 "2019-10-22T12:22:11Z")

</div>

Glad to hear that @ronald_groot_RSF 😊

---

<div class="post-metadata">

**Author:** ![sven](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.silverfin.com/sven/32/1495_2.png) [@sven](https://community.silverfin.com/u/sven)\
**Post date:** [October 22, 2019, 12:22pm UTC](https://community.silverfin.com/t/if-statement-causes-includes-to-stop-working/1589/14 "2019-10-22T12:22:17Z")

</div>

Closed on October 22, 2019, 12:22pm UTC


