Thijs
December 18, 2017, 5:18pm
1
How can I use a result tag in a foriloop?
Reconciliation template code:
{% fori overeenstemming in custom.overeenstemmingen %}
{% input overeenstemming.bedrijfsleider %}
{% assign $1 = 0 %}
{% assign $2 = 0 %}
{% capture bezoldiging_key = %}bezoldiging_{{ overeenstemming.key }}{% endcapture %}
{% fori bezoldiging in custom[bezoldiging_key] %}
{% $1+input bezoldiging.aa %}{% $2+input bezoldiging.bb %}{% endfori %}
Totaal {{ $1+$2 | currency }}
{% result 'totaal' $1+$2 %}
{% endfori %}
Reconciliation input mode:
My text template code:
{{ period.reconciliations.test_totaal.results.totaal | currency }}
Text:
Thijs
December 19, 2017, 7:28am
2
I want to use the $1+$2 of every loop displayed in a text template. I tried to use:
{% fori overeenstemming in period.custom.overeenstemmingen %}
{% input overeenstemming.bedrijfsleider %}
{% assign $1 = 0 %}
{% assign $2 = 0 %}
{% capture bezoldiging_key = %}bezoldiging_{{ overeenstemming.key }}{% endcapture %}
{% fori bezoldiging in custom[bezoldiging_key] %}
{% $1+input bezoldiging.aa %}{% $2+input bezoldiging.bb %}{% endfori %}
Totaal {{ $1+$2 | currency }}
{% assign overeenstemming.bezoldiging_totaal = $1+$2 %}
{% endfori %}
and then:
{% for overeenstemming in period.custom.overeenstemmingen %}
{{ overeenstemming.bezoldiging_totaal }}
{% endfor %}
But didn’t work.
Is there another option?
Hi @Thijs
In the beginning of your fori loop you are assigning $1 and $2 to zero. Your result tag is overwritten at the end of every foriloop. So in the last stage of your loop, your $1 = 0 and your $2 = 0. This is why your totaal = 0 as well…
Concerning your second question: overeenstemming.bezoldiging_totaal is a custom drop variable. Custom drop variables can only be used as an input. You can use assign to safe a variable in a custom drop variable.
My solution looks something like this. Take whatever you want from it.
{% fori overeenstemming in period.custom.overeenstemmingen %}
{% input overeenstemming.bedrijfsleider %}
{% assign $1 = 0 %}
{% assign $2 = 0 %}
{% fori bezoldiging in custom[overeenstemming.key] %}
{% $1+input bezoldiging.aa %}{% $2+input bezoldiging.bb %}
{% endfori %}
{{ $1+$2 | currency }}
{% endfori %}
{% for overeenstemming in period.custom.overeenstemmingen %}
{% assign totaal = 0 %}
{% for bezoldiging in custom[overeenstemming.key] %}
{% assign totaal = totaal+bezoldiging.aa+bezoldiging.bb %}
{% endfor %}
Totaal: {{totaal | currency}}
{% endfor %}