Forum Discussion
Chayce, when able, could you give an example of what the if statement would look like? I was able to do the $prev and it works great. But I only want the fields that changed to show the previous vs new value.
------------------------------
Hannah Engelson
------------------------------
Sure - here is the full online documentation for using Jinja but also below:
{% if a.field != a.$prev.field %} {{ do something here }} {% endif %}
If you need to handle the else if condition you would do
{% if a.field != a.$prev.field %} {{ do something here }}
{% else %} {{do something else}}
{% endif %}
So if your values aren't the same you might just display {{a.field}} like:
{% if a.field != a.$prev.field %} {{ a.field }} {% endif %}
------------------------------
Chayce Duncan
------------------------------
- HannahEngelson2 years agoQrew Trainee
You are a rockstar! I have bookmarked the Jinja link you sent as well. It's a very new language for me. Thank you so so much for this.
------------------------------
Hannah Engelson
------------------------------- ShaneMiller12 years agoQrew Cadet
I have found that if X field in your list of "if" "then" statements wasn't changed, then it adds weird spacing to it. Did you experience the same or did the above solutions work for you?
------------------------------
Shane Miller
------------------------------- HannahEngelson2 years agoQrew Trainee
Shane, I'm unsure what you mean by the fields not being changed. The only thing that held me up was that I put everything I wanted it to do inside the curly brackets, which didn't work. I did get it to work though as it was explained above.
For example, I had the formula below. I had put everything inside the curly brackets of the field name, which didn't work. After fixing it, it works great!
{% if a.employee_id != a.$prev.employee_id %} <b>UPDATE {{a.employee_id}}</b>
{% else %}{{a.employee_id}}{% endif %}
------------------------------
Hannah Engelson
------------------------------
Related Content
- 7 months ago