How can we achieve a field level audit . Can someone suggest step by step .
Discussion posts and replies are publicly visible
For these use cases I prefer to setup an Update triggers on my table which inserts data in to an audit table with details of the changes I want to track e.g. column name, old value, new value, timestamp, user etc.
So users can update as they like and a simple sql trigger can maintain the audit of columns/fields level changes. Below is a sample code for reference :
CREATE TRIGGER persons_update AFTER UPDATE ON persons FOR EACH ROW BEGIN IF OLD.FirstName <> new.FirstName THEN insert into persons_audit_trail(Personid, column_name, old_value, new_value, done_by) values(NEW.Personid,'FirstName',OLD.FirstName,NEW.FirstName,NEW.updated_by); END IF; IF OLD.LastName <> new.LastName THEN insert into persons_audit_trail(Personid, column_name, old_value, new_value, done_by) values(NEW.Personid,'LastName',OLD.LastName,NEW.LastName,NEW.updated_by); END IF; IF OLD.Age <> new.Age THEN insert into persons_audit_trail(Personid, column_name, old_value, new_value, done_by) values(NEW.Personid,'Age',OLD.Age,NEW.Age,NEW.updated_by); END IF; IF OLD.is_deleted <> new.is_deleted THEN insert into persons_audit_trail(Personid, column_name, old_value, new_value, done_by) values(NEW.Personid,'is_deleted',OLD.is_deleted,NEW.is_deleted,NEW.updated_by); END IF; END
As others mentioned you can setup record and drive this whole process from Appian as well, I prefer sql as it helps in performance in my opinion!