ShaneMiller1
2 years agoQrew Cadet
Pipelines Jinja Sum
Hello,
I have a question pertaining to pipelines and the sum function within jinja2.
I have created a pipeline:
Step A: searching through records on table 1
for each A do:
Step B: Look Up a Record on table 2 where the Query is [key field table 2] equals [a.key field table 1]
Step C: Update Record
*for step C I am trying to update a numeric field on table 2 which is a sum of [a.paid_amount] from table 1 where the [key field table 2] equals [a.key field table 1].
I have tried putting the following in Step C for the field that is to showcase the summed value:
{% set total = namespace(value=0) %}
{% for r in a %}
{% set total.value = total.value +
(r.paid_amount|default(0, true)) %}
{% endfor %}
{{ total.value }}
and
{{ a|sum(attribute='paid_amount') }}
I keep getting this error however: Validation error: Incorrect template "{{ a|sum(attribute='paid_amount') }}". TypeError: 'Record' object is not iterable
Any recommendations of any kind would be greatly appreciated. Thank you
------------------------------
Shane Miller
------------------------------
I have a question pertaining to pipelines and the sum function within jinja2.
I have created a pipeline:
Step A: searching through records on table 1
for each A do:
Step B: Look Up a Record on table 2 where the Query is [key field table 2] equals [a.key field table 1]
Step C: Update Record
*for step C I am trying to update a numeric field on table 2 which is a sum of [a.paid_amount] from table 1 where the [key field table 2] equals [a.key field table 1].
I have tried putting the following in Step C for the field that is to showcase the summed value:
{% set total = namespace(value=0) %}
{% for r in a %}
{% set total.value = total.value +
(r.paid_amount|default(0, true)) %}
{% endfor %}
{{ total.value }}
and
{{ a|sum(attribute='paid_amount') }}
I keep getting this error however: Validation error: Incorrect template "{{ a|sum(attribute='paid_amount') }}". TypeError: 'Record' object is not iterable
Any recommendations of any kind would be greatly appreciated. Thank you
------------------------------
Shane Miller
------------------------------