With the launch of softr workflows, I’m interested in creating an audit log for some tables (or field level) within the softr database. Having the workflow create a new record in a logging table is pretty straight forward. I’d like to take it a step further and have the workflow tell me what value within the record changed, including the original and the new value.
Any ideas how to accomplish this?
Has anyone found a way to do this?
I don’t think Softr workflows give you a true before/after diff for a record out of the box yet.
What I’ve seen work is treating the current row as the source of truth and keeping a shadow snapshot table for the fields you care about. On update:
- fetch the current record
- fetch the last snapshot for that record id
- compare only the fields you want to audit
- write one audit-log row per changed field with old value, new value, changed_at, changed_by
- replace the snapshot with the new values
If you only need record-level auditing, the simpler version is just storing the full JSON payload in the log table on every update. Then you can diff it later outside Softr.
If it were me, I’d start with 3 to 5 important fields first instead of trying to track every field in the table. If you want, I can sketch the exact table structure and workflow steps for the snapshot pattern.