Create Custom Event Handler Method

The Administrators need to create Event Handler Methods that will process all events produced by the appropriate Event Type.

The following steps outline the process of creating a custom event handler method:

  1. From the Table of Contents, expand Administration and select Methods. The Methods Table of Contents appears.

  2. Click Create New Method.

    The Method form appears.

  3. In the Name field, enter the name of the method.
  4. The Execution allowed to field should be set to ehf_EventHandlers.
  5. Select Server-Side method.

  6. Add the custom method code for publishing event data from the queue.

    Here is a code sample that demonstrates how to retrieve the event data from the queue for publishing.

    Item relationships = this.getRelationships();

    int eventItemsCount = relationships.getItemCount();

    /* for each event in this batch, get the event details and perform custom publishing logic */

    for (int i = 0; i < eventItemsCount; i++) {

    Item eventItem = relationships.getItemByIndex(i);

    var data = eventItem.node.SelectNodes("./data”);

    string dataXml = string.Empty;

    if (data.Count > 0) {

    dataXml = data[0].InnerXml;

    }

    string subject = eventItem.getProperty(“subject”, string.Empty);

    string type = eventItem.getProperty(“type”, string.Empty);

    string eventId = eventItem.getProperty(“id”, string.Empty);

    string time = eventItem.getProperty(“time”, string.Empty);

    string source = eventItem.getProperty(“source”, string.Empty);

    // add your publishing logic here

    }

    return this;

  7. Click Done to save the changes.