Skip to main content
Question

Creating a record change log table displaying the old/new values of fields from an updated record.

  • August 16, 2023
  • 0 replies
  • 479 views

MattMakris
Forum|alt.badge.img+7

I'd like to track changes made to a record in my `Clients` table by writing the before and after values to a `Change History` table. For instance, if I updated the "Name", "Phone Number" and "Email" field in the `Clients` table , the Pipeline would create a new record for each field updated, showing the old/new values for that field, when it was updated, etc. The Change History records would contain the following fields:

  •  `Field Name`
  • `Old Value`
  • `New Value`

Is there any way to do this in Pipelines? 



------------------------------
Matt Makris
------------------------------
This topic has been closed for replies.

Forum|alt.badge.img+9
  • Registered
  • August 16, 2023

You can use the $prev syntax in pipelines to handle it. If you're looking to track each field individually you might try something like: 

Trigger: When the record changes on any of those fields

IF condition

if a.client_name != a.$prev.client_name

     Log record to change history table logging phone as the field and the a.client_name as value and a.$prev.client_name as old

IF condition

if a.phone != a.$prev.phone

     Log record to change history table logging phone as the field and the a.phone as value and a.$prev.phone as old



------------------------------
Chayce Duncan
------------------------------