Skip to main content
Question

Pipelines - previous value and current value

  • July 26, 2023
  • 0 replies
  • 920 views

Hello, 

I have read up on all the community topics that I can in regards to pipelines and prev values/ current values. I have read through most of the Jinja2 documentation.
From all that I have read, I have created the following jinja2 code within an update step for a field type Text - Multi-line:
{% if a.dba != a.$prev.dba %}
_dba changed from {{ a.$prev.dba }} to {{ a.dba }}
{% endif %}
{% if a.Tax_ID != a.$prev.Tax_ID %}
_Tax ID changed from {{ a.$prev.Tax_ID }} to {{ a.Tax_ID }}
{% endif %}

With this in place, if I change dba and tax_id and then click save, this appears:
_dba changed from 4 to 5_Tax ID changed from 4 to 5
Perfect!!! Exactly what I wanted. I then have a formula text that formats the above field. 

However, if I add more if statements to this jinja2 code:
{% if a.dba != a.$prev.dba %}
_dba changed from {{ a.$prev.dba }} to {{ a.dba }}
{% endif %}
{% if a.Related_Broker != a.$prev.Related_Broker %}
_Related Broker changed from {{ a.$prev.Related_Broker }} to {{ a.Related_Broker }}
{% endif %}
{% if a.Related_GA != a.$prev.Related_GA %}
_Related GA changed from {{ a.$prev.Related_GA }} to {{ a.Related_GA }}
{% endif %}
{% if a.Tax_ID != a.$prev.Tax_ID %}_Tax ID changed from {{ a.$prev.Tax_ID }} to {{ a.Tax_ID }}
{% endif %}

With this code in place, if I change dba and tax_id and then click save, only this appears:
_dba changed from 5 to 6

it completely disregards the fact that I also changed the tax_id. As I understand it, Pipelines should evaluate all the {% if %} statements separately and continue even if any individual if statement is false. Each {% if %} block is independent of the others, and the code inside each block will be executed only if the condition is true.

Am I doing something wrong, misunderstanding something, or is Pipelines at fault for not rendering the environment properly?
Any ideas?



------------------------------
Shane Miller
------------------------------
This topic has been closed for replies.

AdamKrzyzanek
Forum|alt.badge.img+10

Shane, formula IF is evaluating statements from top and stops execute if statement = True.

In your case if you have this statement as one, it finds first TRUE, execute it and drop.

{% if a.dba != a.$prev.dba %}

If you want to evaluate other part of IF, it needs to be separate to different steps in your Pipeline.



------------------------------
Adam Krzyzanek
------------------------------