EventListener procedures

EventListener procedures are used to perform custom actions in reaction to Server Events.

A procedure of this type has the following structure:

Listing 295 Structure of EventListener procedures
1
2
3
4
5
  var listeners = {
      "EventName1": function(context, event) {},
      "EventName2": function(context, event) {},
      ...
  };

Important

The listeners variable must be a JS object where each entry has a key naming the Event to be listened for, and the value being the function that will run in reaction to the event occurring.

See Event for a complete list of which events can be listened for.

Configuring EventListener Procedures

To configure an EventListener procedure, you must first create a Event-listener-procedure containing the script itself, then link to it from an Event-listener instance.

Notice that merely creating a procedure is not enough for the event-listener to become active. It must be added to the list of event-listener-procedures to become active.

EventListener functions

Each listener function takes two arguments: the Context object, as well as the event itself. The event will be of the type the function listens for, or a sub-type of it.

function(context, event)

Implementation of an event listener.

param context:The context object for event-listener-procedures
param event:The event object, which will be of the type listened for or one of its sub-types.
returns:nothing

Context

context

First input argument to an event-listener function. It contains the following attributes

context.exceptionFactory
Returns:exceptionFactory the ExceptionFactory object.
context.json
Returns:json the Json (de-) Serializer object.
context.webServiceClient
Returns:webServiceClient configured for the procedure, or null if none is configured.
context.smsSender
Returns:smsSender configured for the procedure, or null if none is configured.
context.emailSender
Returns:emailSender configured for the procedure, or null if none is configured.
context.accountManager
Returns:accountManager configured for the procedure, or null if none is configured.