The IEventSender API provides methods to send events from a MID Server to a ServiceNow instance and to query the status of the event queue.

Before calling any methods within this class, you must call the SNEventSenderProvider.getEventSender() method to instantiate an IEvent object.

Use the Event API to add/update fields within an event. Use the SNEventSenderProvider API to instantiate an event sender object. Then use the IEventSender API to send the event to a ServiceNow instance.

You must activate the Event Management (com.glideapp.itom.snac) plugin before attempting to access this API. The Event Management plugin requires a separate subscription and must be activated. This plugin includes demo data and activates related plugins if they are not already active.

For additional information on event management, see Event Management.

IEventSender - getQueueSize()

Returns the size of the event queue.

Table 1. Parameters
Name Type Description
None
Table 2. Returns
Type Description
Number Size of the event queue.

If an event queue is not currently implemented, returns "0".

Example

var event = new Event();
event.setField("source","SAP Solman");
event.setField("severity","3");
event.setField("time_of_event", "2019-18-05 13:12:05");
event.setField("type", "SAP object");
event.setField("user", "admin"); // parameter added to additional info section

var eventSender = SNEventSenderProvider.getEventSender();
var sendStatus = eventSender.sendEvent(event); //send event     
var queueSize = eventSender.getQueueSize() // check the size of the event queue

IEventSender - isFullQueue()

Checks if the event queue has exceeded its maximum size.

Table 3. Parameters
Name Type Description
None
Table 4. Returns
Type Description
Boolean Flag that indicates whether the event queue has exceeded its maximum size. When this happens, no additional event messages can be queued until the queue decreases in size.
Valid values:
  • true: Event queue is full.
  • false: Event queue is not full and can add more event entries.

Example

var eventSender = SNEventSenderProvider.getEventSender();
if (!eventSender.isFullQueue()) // If queue is not full, send event
  eventSender.sendEvent(event);     

IEventSender - sendEvent(Object event)

Places the specified event in the event queue.

Table 5. Parameters
Name Type Description
event IEventSender Event object to place in the events queue.
Table 6. Returns
Type Description
Boolean Flag that indicates whether the event was successfully queued
Valid values:
  • true: Event was queued
  • false: Error

Example

var eventSender = SNEventSenderProvider.getEventSender();
eventSender.sendEvent(event); //send event