Skip to main content
Question

Pipeline Jinja template expression

  • April 20, 2022
  • 0 replies
  • 654 views

Hello, I am looking for a jinga expression/syntax which could help me validate the sum(Field-1) > NN value in a step using if condition.  

Below is the pipeline steps:
Table-B structure
Record ID#, country, Qty issued
1, UK, 20.5,
2, UK, 30
3, UK, 30.8

Pipeline

Step-A
     When the record is created in table-A
Step-B
     Search records in Table-B  where b.country =  "UK"
     If sum(qty) >= 100
               Step-C - Create record in Table-C 
     Else
              Step-D - Create record in Table-D

I want the jinga expression to be added in step-B post search is returned to check the sum(qty) and compare if it exceed or equals 100







------------------------------
MC 
------------------------------
This topic has been closed for replies.

QuickBaseJunkie
Forum|alt.badge.img+15
@MC Admin You are on the right track.

If your ​'no_of_days' attribute/field is required and will not have any null values you can use this approach:

{{ (d|sum(attribute='no_of_days')) >= 100 }}

However, if there may be null values in the 'no_of_days' field a different approach is necessary.

{% set total = namespace(value=0) %}
{%
for r in d %}
{%
set total.value = total.value + (r.no_of_days|default(0, true)) %} {% endfor %}
{{ total.value >= 100 }}


The above creates a 'total' variable with an initial value of 0. Then loops through the records found in Step D adding them together, while setting a default value of 0 if null. Then it evaluates it against the value of 100 for the condition.

To learn more about using Jinja in Pipelines I suggest taking the "Intro to Jinja for Pipelines" course. It includes a Library of Jinja references for Pipelines including approaches such as this.  https://www.quickbasejunkie.com/intro-to-jinja

Let me know if this works and what approach ended up doing the job. 👍

-Sharon

------------------------------
Quick Base Junkie
------------------------------