Consolidating the Audit Trail
Many user activities are recorded in LOG tables throughout the application. While you can view activity for a particular item in the properties panel audit trail viewer there is no centralised viewing screen, which makes it difficult to view a user's activity across the system.
The attached script builds a temporary table and copies in some basic information from all existing log tables, enabling a simple overview of activity. Each row in the table contains:
- the name of the table that the log entry came from
- the name of the parent record (where available)
- the name of the user that made the change
- the time that the change was made
- the type of change (add, modify, delete)
This has the potential to build a huge table, so the date range examined is limited, controlled via two variables. The default period is (Today - 7 days). Change these variables at the top of the script to draw in a wider time period.
You can query the consolidated log to find, for example, a history of all events:
-- A history of all events
SELECT * FROM #EventHistory
ORDER BY ByTime;
A history of events logged against a single user's name:
-- Events from a particular person
SELECT * FROM #EventHistory
WHERE ByName = 'Some Person'
ORDER BY ByTime;