Exploring the "EditHistory" user-activity audit table
Orixa provides a built in, simple mechanism for tracking user activity (logging on, editing, adding, deleting records, running reports and resources). This is done by automated addition of records to a System data-table called "EditHistory".
The following help-topic shows how you can use this data-table to track user's use of your Orixa App.
Note: Before reading this topic in detail you may want to read an introduction to the EditHistory system data-table:
The EditHistory Dashboard
Many Orixa Apps include a built in "EditHistory Dashboard" resource. Running this resource will show a view of activity in the EditHistory data-table which may be useful. Your developer can extend this dashboard (or add additional ones) so that it fully meets your needs. To explore this dashboard, find the Resources system-table and look for records with the name "EditHistory Dashboard", these should be linked to UI in your App, but if they are not, you can set the "LocationID" so that the Dashboard is surfaced, and then run it and edit it's design to meet your needs.
The structure of the EditHistory data-table, and how it is populated with data
CREATE TABLE "EditHistory"
(
"ID" INTEGER DEFAULT UID() NOT NULL,
"LinkID" INTEGER,
"StatusID" INTEGER,
"LinkTable" VARCHAR(50) COLLATE "ANSI",
"DateCreated" TIMESTAMP DEFAULT Current_Timestamp,
"ChangeType" VARCHAR(50) COLLATE "ANSI",
"AuthorID" INTEGER,
CONSTRAINT "PK_EditHistory" PRIMARY KEY ("ID")
)
The EditHistory data-table has a simple structure. Each row in the table records one change to one record in one data-table by one user. It contains a LinkID and LinkTable columns which create a direct link to the changed record. It contains an AuthorID column which links to the user, and it contains a "DateCreated" column which records the exact date and time that the change occured.
If the data-table being changed contains a "StatusID" field, then the value of this field (at the moment of the EditHistory timestamp) is also recorded.
EditHistory contains one other field a "ChangeType" which is a simple alphanumeric field which records
Records are added to the EditHistory data-table when a User:
- Logs On
- Adds, Edits or Deletes a record.
- A User "unclicks" the "Complete" tickbox of a record, to edit it after another user has marked it "Complete"
- A User runs any Resource. (The ID and name of the resource are also recorded in the "ChangeType" column.
- A User runs any "Search" of a Grid. The name of the Grid that was searched and the name of the Search is recorded.
- Your developer may add additional special EditHistory actions. For example when a "Rapid Entry Grid" is run, a record is often made into the Edit History table.
Examples of useful scripts to explore the data recorded in the EditHistory data-table
SELECT
P.FullName as Author,
YearMonth(CAST(DateCreated as Date)) as LogOnDate,
COUNT(*)
FROM EditHistory EH
LEFT JOIN People P ON P.ID = EH.AuthorID
WHERE ChangeType LIKE 'Log On%'
GROUP BY Author, LogOnDate
ORDER BY LogOnDate
The above script creates a result set which lists the number of times every user of your Orixa App has logged on every month. Note that this script uses the "YearMonth" SQL Function.
SELECT
P.FullName as Author,
LinkTable,
COUNT(*) as CountDel
FROM EditHistory EH
LEFT JOIN People P ON P.ID = EH.AuthorID
WHERE ChangeType LIKE 'Del'
GROUP BY Author, LinkTable
ORDER BY CountDel DESC
The above script creates a result set which lists the number of times each user has deleted a record from any data-table, together with the names of the table.