If statement causes includes to stop working

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

{% 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:
{% 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:

{% 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?

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:

{% 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 :blush:

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

{% 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.

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).

{% 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?

So here’s the code now:

{% 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:

{% 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:

{% 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" %}

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

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

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?

{% 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…

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 :slightly_smiling_face:

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…

Oh and thanks for your help so far @sven :smiley:

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 :upside_down_face:
Feel free to fill me in on this @ronald_groot_RSF

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.

1 Like

Glad to hear that @ronald_groot_RSF :blush: