Value not visible on preview

When I put a variable into a column with a fori loop the value is not showing on the preview in a template. In a document it does show in the preview. The variable is in a if statement and when I remove the if statement then it shows again. Does anyone knows what the problem is?

{% if forloop.first %} {% $0+input titeldetail.valuestart as:currency placeholder:'waarde' default:detail.custom.value %} {% else %} {% if mycalc %} {{ sub | currency }} {% else %} {% $0+input titeldetail.valuestart as:currency placeholder:'waarde' %}{% endif %} {% endif %}

this does work on the preview, so it is not a problem with the value
{% if forloop.first %} {% $0+input titeldetail.valuestart as:currency placeholder:'waarde' default:detail.custom.value %} {% else %} {{ sub | currency }} {% endif %}

Hi Peter,

Unfortunately we cannot say this based on the code you shared. Can you share some more code (like the complete fori statement)? How are variables mycalc and sub defined?

For now I would think that mycalc does not equal true and therefore it does not show sub, but we need more code to be sure.

Best regards,

Michiel

Hi Michiel,

Mycalc has the value true because it works in the account template but not in the preview.
Hereby the code for the fori statement

{% fori titeldetail in custom[detail.custom.title.key] %} 
  | 
  | {% ic %}{% if forloop.first %} {% input titeldetail.info as:text size:mini placeholder:'omschrijving' default:detail.custom.text %} {% else %} {% input titeldetail.info as:text size:mini placeholder:'omschrijving' %}{% endif %}{% endic %} {% nic %}{{ titeldetail.info | multiline_table}}{% endnic %}
  | {% if forloop.first %} {% $0+input titeldetail.valuestart as:currency placeholder:'waarde' default:detail.custom.value %}
    {% else %} {% if mycalc %} {{ sub | currency }} {% else %} {% $0+input titeldetail.valuestart as:currency placeholder:'waarde' %}{% endif %} 
    {% endif %}  
  | {% input titeldetail.formule as:select options:"+|-|x|:" option_values:"1|2|3|4" %}
  | {% $1+input titeldetail.value as:currency placeholder:'waarde' %}
  | {% ic %}{% input titeldetail.type as:boolean %}{% endic %} {% nic %}{% if titeldetail.type == 'true' %}%  = {% else %}={% endif %}{% endnic %}
  | {% if titeldetail.type == 'true' %} {% assign perc=100 %} {% else %} {% assign perc=1 %} {% endif %}
    {% assign sub=0 %}
    {% case titeldetail.formule %}
      {% when 1 %}
        {% assign sub=$0+($1/perc) %}
      {% when 2 %}
        {% assign sub=$0-($1/perc) %}
      {% when 3 %}
        {% assign sub=$0*($1/perc) %}
      {% when 4 %}
        {% assign sub=$0/($1/perc) %}
      {% endcase %} 
      {% if forloop.last %}_{% endif %}{{ sub | currency }}{% if forloop.last %}_{% endif %}
      {% if mycalc %}
        {% ic %}{% unless forloop.last %} {% assign sub1=sub %} {% endunless %}{% endic %}
        {% nic %}{% assign sub1=sub %}{% endnic %} 
      {% else %}
        {% ic %}{% unless forloop.last %} {% assign sub1=sub1+sub %} {% endunless %}{% endic %}
        {% nic %}{% assign sub1=sub1+sub %}{% endnic %} 
      {% endif %}
      {% if mycalc %} {% assign $0 = sub %} {% else %} {% assign $0 = 0 %} {% endif %} 
      {% assign $1= 0 %} 
      {% newline %}
  {% endfori %}

Template view


Preview

Hi MIchiel,

I found the problem, I’ve assigned a boolean to mycalc immediately after the boolean input, but this stands between {{ic-endic}} statement because this doesn’t to be show in the preview. So I replaced the place where I assign the boolean to mycalc after the {{endic}} and now it works fine.
Already thanks for your help.

Glad to hear that Peter!