Forum Discussion

HannahEngelson's avatar
HannahEngelson
Qrew Trainee
10 months ago

Pipeline to highlight only changed fields

Hello! I'm trying to create an email notification that kicks out when there is a change to a record. I've looked at the email notifications and the default message includes a copy of the record with the information changed in red. Is there a way to put that or something similar into a Pipeline trigger with changes highlighted somehow? There are several reasons I don't like the email notifications option but we are using like 15 fields and I can't find a way to highlight what actually was changed in Pipelines. Thank you!



------------------------------
Hannah Engelson
------------------------------

8 Replies

  • You can use the $prev syntax within a field reference in Pipelines as a way to look at the prior value. You may have to get creative with your email but you can highlight the value of a field and its prior value using {{a.field}} and {{a.$prev.field}}. 

    What that means for your email is a little trickier - you could do something super generic like: 

    Field Value: Current: {{a.field}} / Prior: {{a.$prev.field}}

    If you want a more styled email you'll probably have to get creative with doing {% if %} conditions to check if the value is different and then try and change the email accordingly. 



    ------------------------------
    Chayce Duncan
    ------------------------------
    • HannahEngelson's avatar
      HannahEngelson
      Qrew Trainee

      This is a helpful start. Thank you!



      ------------------------------
      Hannah Engelson
      ------------------------------
    • HannahEngelson's avatar
      HannahEngelson
      Qrew Trainee

      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
      ------------------------------
      • ChayceDuncan's avatar
        ChayceDuncan
        Qrew Captain

        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
        ------------------------------