As most folks who work with CCA\UII know, UII has its own auditing system that audits events for the agent desktop. I recently was asked how to go about adding a custom audit event and storing that information in UII’s audit system.
Audit events shipped with UII
These are events that are installed by default… by default they are all disabled. To enable, you need to flip the bits in the UII Options entity to 1 for the events your interested in.
|Flag Name||What it does|
|AuditFlagAction||Raised when an action is called on a hosted control|
|AuditFlagAgentState||Raised when the CTI State of an agent changes|
|AuditFlagHostedApplication||Raised when a hosted application changes or is loaded|
|AuditFlagInteraction||Can be raised by a developer code as necessary|
|AuditFlagLogin||Raised when a UII Login or Logout event occurs|
|AuditFlagSession||Raised when a session is changed, loaded or closed.|
|AuditFlagWorkFlow||Raised when the onboard workflow system is used with state information on the workflow|
So that’s great, Now how to I add my OWN events.
Adding an audit event to catch the desktop shutdown.
Lets say I want to log the desktop shutdown, as you can see that’s not covered in the out of the box list. Lets add it.
Right Way vs Just getting it done…
As with most things in coding, there are multiple ways to do something, UII is no different. in this case, I’m going to cover what I suggest is the correct way to add in a log event and provide a means for the operations folks that come behind you to maintain it and switch it.
First thing to do is add a new value to the UII Options table, lets call this value "AuditFlagDesktopShutdown”.
Goto Settings –> UII Options. Press the new button and add the entry as it appears below.
Ok now to our Agent desktop code,
In the agent UiiServices class, locate the method “BeforeDesktopClose”
Add this code to it
This code is broken into two parts. The first part is the setup and registration of the audit key in the desktop. Where the call to ConfigurationReader.ReadAppSettings is reading the key from the UII Options entity.
The set command registers it with UII for future use. as such you only need to do this part once at the start of your desktop normally. Once this is done, UII will respect the audit setting and either log or not log the event based on the setting.
The second part is where the actual log event occurs.
Once that is done you can use an Advanced find to locate the and see the UII Audit entity in CRM.
For clarity sake, my UII Options entity looks like this :