Auditing

WorkWithPlus provides the possibility to audit transactions for every action executed. This has as a result that after each action is executed in transactions where Auditing is enabled, a procedure will be invoked on which user has full control.

The target of the Auditing procedure is to let user develop his own way of auditing the processes mentioned above. For instance, we could develop that each time a new record of some transaction is inserted in database, we insert some log record in order to notify about it, or send notifications to the people involved.

As to enable this functionality we must select the instance´s main node, as to modify one of its properties.

AuditingImg01

We set True to the property Enable Auditing :

AuditingImg02

An then we save the object. After this we can appreciate that a procedure named LoadAuditPerson has been created in the instance of the Person transaction:

AuditingImg03

This procedure loads in the SDT 'AuditingObject' the following information:

- Name of the transaction in which the action was executed
- Action audited (insert, update, delete). This is included for the first level of the transaction and for each item of the second one.
- For each attribute:

  •  If it belongs to the primary key
  •  If it is the description attribute of the transaction
  •  Old Value (when you update o remove a record)
  •  New Value (when you insert or update a record)

That is the reason why in the Rules of the Person transaction the pattern adds the following code:

AuditingImg04

There is a property in WWP Configuration, Template node which determines whether the auditing will be done just to first level of the transaction or to first and second levels. The differences will be the procedure which loads the information and the rules whick call the procedure. This property is Auditing Levels.

In the After Trn event the pattern invokes the Audit Transaction procedure:

AuditingImg05

This procedure will decide what activities (logs, notifications, etc.) will be accomplished with the information obtained about the executed action. It has no code by default, because it is user who must decide what he wants to do when auditing some transaction. It will receive an SDT with all the information of the action.

AuditingObject has the following structure:

AuditingImg06

It contains the Mode of the action (Insert, Update, Delete), the name of the table where the record belongs and for each attribute of the transaction, contains its name, whether it belongs to the primary key of trn and its old and new value.

The old value applies when it is an update or deletion and the new value for insert and update (because when it is a deletion there is no new value). 

Both objects are located inside Auditing folder.

AuditingImg07

An example of Auditing could be creating a transaction 'Audit', bussiness component with some information like the following:

AuditingImg08

Then, in the AuditTransaction procedure, I could codify the behaviour of creating a record of this transaction every time it is invoked, with the information of user, attributes that have changed, date and time, and others. This procedure contains some suggested instructions in order to save in DataBase the changes made in the transactions.

AuditingImg09

Then, if I apply WorkWithPlus pattern to Audit transaction, I could view the auditing information, like this:

AuditingImg10

AuditingImg11

This is just an example of using Auditing, but developer can do whatever he wants with the auditing information.