Insights does not seem to fetch the correct result tag

I’m having an issue with Insights. When I’m running this template:

{% comment %}Assign variables for reconciliation{% endcomment %}
{% assign check_CBO = 0 %}
{% assign check_Bespreekpunten = 0 %}
{% assign check_terugkoppeling = 0 %}

{% comment %}Assign variables for results{% endcomment %}
{% assign question_count = 0 %}
{% assign yes_count = 0 %}
{% assign reaction_feedbackloop_201 = 0 %}

{% if custom.close_CBO.value != "Y" %}
  {% assign check_CBO = check_CBO+1 %}{% unreconciled 1 %}
{% else %}
  {% assign yes_count = yes_count+1 %}{% endif %}
{% if custom.CBO_report.value != "Y" %}
  {% assign check_CBO = check_CBO+1 %}{% unreconciled 1 %}
{% else %}
  {% assign yes_count = yes_count+1 %}
{% endif %}
{% if custom.closing.general == blank %}
  {% assign check_CBO = check_CBO+1 %}{% unreconciled 1 %}
{% else %}
  {% assign yes_count = yes_count+1 %}
{% endif %}
{% if custom.closing.discussiontopics == blank %}
  {% assign check_Bespreekpunten = check_Bespreekpunten+1 %}{% unreconciled 1 %}
{% else %}
  {% assign yes_count = yes_count+1 %}
{% endif %}

{% if period.custom.discussed.value != "Y" %}
  {% assign check_terugkoppeling = check_terugkoppeling+1 %}{% unreconciled 1 %}
{% else %}
  {% assign yes_count = yes_count+1 %}
{% endif %}

{% if custom.discussed.date == blank %} 
  {% assign check_terugkoppeling = check_terugkoppeling+1 %}{% unreconciled 1 %}
{% else %}
  {% assign yes_count = yes_count+1 %}
{% endif %}

{% if custom.discussed.response == blank %}
  {% assign check_terugkoppeling = check_terugkoppeling+1 %}{% unreconciled 1 %}
{% else %}
  {% assign yes_count = yes_count+1 %}
{% endif %}

{% stripnewlines %}
{{ default_table }}
{% newline %}
|{% unreconciled check_CBO as:indicator%}
|**{::font size='l'}Cijferbeeld{:/font}**
|
{% newline %}
|
|Zijn de belangrijkste grootboekrekeningen nagelopen? {% assign question_count = question_count+1 %} 
|{% input custom.close_CBO.value as:select options:yes_no option_values:values %}
{% newline %}
|
|Sluit de nettowinst over periode 1 t/m de huidige periode aan met de winst in de gepresenteerde rapportage?
|{% input custom.CBO_report.value as:select options:yes_no option_values:values %}
{% newline %}
|
|Formuleer hieronder een algemeen beeld bij de cijfers {% assign question_count = question_count+1 %} 
|
{% newline %}
|
|{% input custom.closing.general placeholder:"vul in" as:text %}
|
{% newline %}
|{% unreconciled check_Bespreekpunten as:indicator %}
|**{::font size='l'}Bespreekpunten{:/font}**
|
{% newline %}
|
|Geef hieronder kort aan welke punten je met de opdrachtgever wil bespreken. {% assign question_count = question_count+1 %} 
|
{% newline %}
|
|{% input custom.closing.discussiontopics placeholder:"vul in" as:text %}
|
{% newline %}
| 
|^_**{{ period.reconciliations.RS201.name }}**_^
| 
{% if period.reconciliations.RS201.results.Bespreekpunten_hoofdstuk_3_liq_mid_YN == "Y" %}
  {% newline %}
  |
  |{{ period.reconciliations.RS201.results.Bespreekpunten_hoofdstuk_3_liq_mid }}
  |
  {% newline %}
  |
  |{% input custom.discussionpoints_h3.cash as:text placeholder:"Reactie opdrachtgever" %}
  |
{% endif %}
{% if period.reconciliations.RS201.results.Bespreekpunten_hoofdstuk_3_verkoop_YN == "Y" %}
  {% newline %}
  |
  |{{ period.reconciliations.RS201.results.Bespreekpunten_hoofdstuk_3_verkoop }}
  |
  {% newline %}
  |
  |{% input custom.discussionpoints_h3.sales as:text placeholder:"Reactie opdrachtgever" %}
  |
{% endif %}
{% if period.reconciliations.RS201.results.Bespreekpunten_hoofdstuk_3_inkoop_YN == "Y" %}
  {% newline %}
  |
  |{{ period.reconciliations.RS201.results.Bespreekpunten_hoofdstuk_3_inkoop }}
  |
  {% newline %}
  |
  |{% input custom.discussionpoints_h3.purchases as:text placeholder:"Reactie opdrachtgever" %}
  |
{% endif %}
{% if period.reconciliations.RS201.results.Bespreekpunten_hoofdstuk_3_vraagposten_YN == "Y" %}
  {% newline %}
  |
  |{{ period.reconciliations.RS201.results.Bespreekpunten_hoofdstuk_3_vraagposten }}
  |
  {% newline %}
  |
  |{% input custom.discussionpoints_h3.unspecified_posts as:text placeholder:"Reactie opdrachtgever" %}
  |
{% endif %}
{% if period.reconciliations.RS201.results.Bespreekpunten_hoofdstuk_3_lonen_YN == "Y" %}
  {% newline %}
  |
  |{{ period.reconciliations.RS201.results.Bespreekpunten_hoofdstuk_3_lonen }}
  |
  {% newline %}
  |
  |{% input custom.discussionpoints_h3.wages as:text placeholder:"Reactie opdrachtgever" %}
  |
{% endif %}
{% if period.reconciliations.RS201.results.Bespreekpunten_hoofdstuk_3_activa_YN == "Y" %}
  {% newline %}
  |
  |{{ period.reconciliations.RS201.results.Bespreekpunten_hoofdstuk_3_activa }}
  |
  {% newline %}
  |
  |{% input custom.discussionpoints_h3.assets as:text placeholder:"Reactie opdrachtgever" %}
  |
{% endif %}
{% if period.reconciliations.RS201.results.Bespreekpunten_hoofdstuk_3_rek_cour_YN == "Y" %}
  {% newline %}
  |
  |{{ period.reconciliations.RS201.results.Bespreekpunten_hoofdstuk_3_rek_cour }}
  |
  {% newline %}
  |
  |{% input custom.discussionpoints_h3.cur_account as:text placeholder:"Reactie opdrachtgever" %}
  |
{% endif %}
{% newline %}
| 
|^_**{{ period.reconciliations.RS301.name }}**_^
| 
{% if period.reconciliations.RS301.results.Bespreekpunten_hoofdstuk_4_cijferbeeld_YN == "Y" %}
  {% newline %}
  |
  |{{ period.reconciliations.RS301.results.Bespreekpunten_hoofdstuk_4_cijferbeeld }}
  |
  {% newline %}
  |
  |{% input custom.discussionpoints_h4.figures as:text placeholder:"Reactie opdrachtgever" %}
  |
{% endif %}
{% newline %}
| 
|^_**{{ period.reconciliations.RS401.name }}**_^
| 
{% if period.reconciliations.RS401.results.Bespreekpunten_hoofdstuk_5_geldstromen_YN == "Y" %}
  {% newline %}
  |
  |{{ period.reconciliations.RS401.results.Bespreekpunten_hoofdstuk_5_geldstromen }}
  |
  {% newline %}
  |
  |{% input custom.discussionpoints_h5.cashflows as:text placeholder:"Reactie opdrachtgever" %}
  |
{% endif %}
{% if period.reconciliations.RS401.results.Bespreekpunten_hoofdstuk_5_ouderdom_YN == "Y" %}
  {% newline %}
  |
  |{{ period.reconciliations.RS401.results.Bespreekpunten_hoofdstuk_5_ouderdom }}
  |
  {% newline %}
  |
  |{% input custom.discussionpoints_h5.aging as:text placeholder:"Reactie opdrachtgever" %}
  |
{% endif %}
{% if period.reconciliations.RS401.results.Bespreekpunten_hoofdstuk_5_activa_mva_YN == "Y" %}
  {% newline %}
  |
  |{{ period.reconciliations.RS401.results.Bespreekpunten_hoofdstuk_5_activa_mva }}
  |
  {% newline %}
  |
  |{% input custom.discussionpoints_h5.assets_ifa as:text placeholder:"Reactie opdrachtgever" %}
  |
{% endif %}
{% if period.reconciliations.RS401.results.Bespreekpunten_hoofdstuk_5_ohw_voorraad_YN == "Y" %}
  {% newline %}
  |
  |{{ period.reconciliations.RS401.results.Bespreekpunten_hoofdstuk_5_ohw_voorraad }}
  |
  {% newline %}
  |
  |{% input custom.discussionpoints_h5.constr_inventory as:text placeholder:"Reactie opdrachtgever" %}
  |
{% endif %}
{% if period.reconciliations.RS401.results.Bespreekpunten_hoofdstuk_5_leningen_YN == "Y" %}
  {% newline %}
  |
  |{{ period.reconciliations.RS401.results.Bespreekpunten_hoofdstuk_5_leningen }}
  |
  {% newline %}
  |
  |{% input custom.discussionpoints_h5.loans as:text placeholder:"Reactie opdrachtgever" %}
  |
{% endif %}
{% if period.reconciliations.RS401.results.Bespreekpunten_hoofdstuk_5_lonen_YN == "Y" %}
  {% newline %}
  |
  |{{ period.reconciliations.RS401.results.Bespreekpunten_hoofdstuk_5_lonen }}
  |
  {% newline %}
  |
  |{% input custom.discussionpoints_h5.wages as:text placeholder:"Reactie opdrachtgever" %}
  |
{% endif %}
{% if period.reconciliations.RS401.results.Bespreekpunten_hoofdstuk_5_btw_YN == "Y" %}
  {% newline %}
  |
  |{{ period.reconciliations.RS401.results.Bespreekpunten_hoofdstuk_5_btw }}
  |
  {% newline %}
  |
  |{% input custom.discussionpoints_h5.vat as:text placeholder:"Reactie opdrachtgever" %}
  |
{% endif %}
{% newline %}
|{% unreconciled check_terugkoppeling as:indicator %}
|**{::font size='l'}Terugkoppeling{:/font}**
|
{% newline %}
|
|Zijn de bovenstaande bespreekpunten met de opdrachtgever doorgenomen? {% assign question_count = question_count+1 %}
|{% input period.custom.discussed.value as:select options:yes_no option_values:values %}
{% if period.custom.discussed.value == "Y" %}
  {% newline %}
  |
  |Wanneer is deze bespreking geweest? {% assign question_count = question_count+1 %}
  |{% input custom.discussed.date as:date %}
  {% newline %}
  |
  |Geef hieronder een korte samenvatting van de reactie van de opdrachtgever. {% assign question_count = question_count+1 %}
  |
  {% newline %}
  |
  |{% input custom.discussed.response placeholder:"vul in" as:text %}
  |
{% endif %}
{% endstripnewlines %}

{% comment %}Voortgang template meten:{% endcomment %}
{% if question_count > 0 and yes_count > 0  %}
  {% assign completion = yes_count/question_count*100 %}
{% else %}
  {% if yes_count = 0 %}
    {% assign completion = 0 %}
  {% endif %}
  {% if question_count = 0 %}
    {% assign completion = 100 %}
  {% endif %}
{% endif %}

{% capture completion% %}{{ INT(completion) }}%{% endcapture %}
{% result 'Aantal vragen' question_count %}
{% result 'Aantal Ja' yes_count %}
{% result 'Voortgang' completion% %}

In debug mode I get the following results for a certain template:

Named Results

{ “Aantal vragen”: “4.0”, “Aantal Ja”: “1.0”, “Voortgang”: “25%” }

However when I’m fetching these results in Insights I get:
{ “Aantal vragen”: “0”, “Aantal Ja”: “0”, “Voortgang”: “0%” }

Can somebody help me figure out why this is happening? I’m assuming the usage of period.custom variables is somehow causing this issue, as it does not occur in templates where I’m only using custom variables.

Please note that the use of the period.costom variable is by design, and I cannot do without this variable or put it in a regular custom variabel (because I’m fetching a result tag from a different template and I want this variable to be shown in that template).

Hi Ronald

Could you check if the problem is still occurring? There could’ve been some delay on the values that were taken into the insights query.
In case it’s still not taking the correct values could you forward us some more information about the file(s) in which this problem is occurring to support@silverfin.com.

Kind regards
Wouter

I have found the issue! There was an if statement around the code that was causing a problem:

{% comment %}Start uitsluiting partneromgeving{% endcomment %}

{% comment %}For internal use only{% endcomment %}
{% if isrs != blank %}
  {% unless user.email contains "finance.com" and user.email contains "rs"%}
    {% assign hidecontent = 1 %}
  {% endunless %}
{% endif %}


{% if hidecontent == 1 %}
  {{ rsonly }}
  {% else %}
  {% comment %}Eind uitsluiting partneromgeving{% endcomment %}

Insights fetching the data from the template causes ‘hidecontent]’ to show 1, so my counter on a question level is never used by Insights. So it counts the number of questions as 0.

Is there someway I can grant access to Insights within the same if statement? so something like:

{% if isrs != blank %}
  {% unless user.email contains "finance.com" and user.email contains "rs"%}
      **{% unless user == silverfininsights %}**
    {% assign hidecontent = 1 %}
      {% endunless %}
  {% endunless %}
{% endif %}