IEvent AddIns

Tags: 

A few specialized events are exposed through the add-in framework. These can be very helpful when trying to create a complete solution.

IEvent add-ins are very simple add-ins that exist for the lifetime of the session, they don't support user interface elements and only provide notification
of events.

There are two main categories of events:

  • Session Events
    • IEventConsoleClose
    • IEventConsoleOpen
    • IEventLogin
    • IEventLogout
  • Record Events (the #2 interfaces differ slightly but provide the same functionality)
    • IEventDeleted and IEventDeleted2
    • IEventDeleting and IEventDeleting2

Order of execution for the session based events is IEventLogin, IEventConsoleOpen, IEventConsoleClose, IEventLogout.
If your site has multiple interfaces and a user switches between CX consoles from the Links menu additional ConsoleOpen and
ConsoleClose events will be fired, but not Login and Logout. You would expect to be able to use the automation context on ConsoleOpen
to be able to open a workspace record or content pane, but there appears to be a product defect which keeps this from functioning properly,
see this response for a possible workaround.

The other set of events lets you monitor when an object is being deleted. The event is fired regardless of how the record is being deleted,
whether through a report or through a workspace, which makes it very helpful for auditing user interactions. The Deleting events allow you to
cancel a delete by returning a boolean value when the event is fired. Most record types are supported; Contact, Incident, Account, etc, but not everything. Profile for instance is not and neither are analytics reports or workspaces.
The example below will prompt a user if they want to continue to delete
the record. Selecting 'No' from the dialog will cancel the delete (it also logs the event details to the add-in log).


[AddIn("Deleting")]
public class Deleting : IEventDeleting2
{
public bool Initialize(IGlobalContext context)
{
this.context = context;
return true;
}

public bool Notify(int recType, string typeName, long recId)
{
context.LogMessage(string.Format("--------------------------------------IEventDeleting2 - recType: {0}, typeName: {1}, recId: {2}", recType, typeName, recId));

return MessageBox.Show("Allow Delete?","", MessageBoxButtons.YesNo) == DialogResult.Yes;
}

public IGlobalContext context { get; set; }
}

Personally I would love to see additional events added to the add-in framework. The additions of ICreated and IUpdated
for example would allow for a complete auditing package to be created without having to rely on CPMs or workspace add-ins
to cover the missing functionality. In general though IEvent add-ins are an important tool for a CX Developer and can
simplify an otherwise complex integration.

A very simple demo of Event Add-ins is available on BitBucket under /AddIns/Events/

Zircon - This is a contributing Drupal Theme
Design by WeebPal.