While the submit workflow is great for transactions, it does cover documents that keep changing, like Customer details, contacts. If someone changes an address you lose the earlier information. If someone changed the credit rating of a customer, then
it is important to know who did it when.
Inspiration
Since we use GitHub a lot, we love the way GitHub adds changes to an Issue to the timeline.
This seemed like a really nice way to track changes.
Implementation
Also since Frappé Framework had its own ORM, adding a new event listener seemed like an easy thing to do. So I wrote out a basic todo list on a GitHub Issue.
We already had a basic versioning system with a DocType "Version" but it was only activated for Web Page and Blog Post, so it made sense to extend it.
The implementation is really simple. Everytime a document is saved, and if versions are tracked, the ORM runs a basic difference check on the document structure before and after the update saving:
- Properties that changed
- Rows added
- Rows removed
- Properties in child tables that are changed.
Once this information is stored, we load the Version in the timeline along with other communications and render the history, a bit like GitHub
Since document changes can be extensive, only a small fraction of the details are shown and the user can click on the link and see the detailed difference.
Cleanups
The moment I built this, I was obvious that some of the other changes (like adding, removing of assignments, attachments, sharing) should be a part of the Versioning and not Communication. So I just changed the implementation of the
add_comment
method
to update the Version table instead of CommunicationStretch Goal
What was left was deletions, when a document was deleted, currently there was no delete log. So we added a new document type Deleted Document, that keeps a log of all deleted records. What's more, you can restore them too!