Monday, November 6, 2017

How to work with Events in Service Now ?



·        One use for system events in the ServiceNow platform is to control email notification for system activity, such as when incident records are updated, or change requests are assigned.

·        There are  number of useful OOB events that provides you with a broad view of application activity
·        If existing events do not meet your needs, you can create your own events to watch for specific changes to ServiceNow records.

·        Administrators can create a custom event to send an email notification if an existing business rule does not provide the necessary event. For example, you might want to notify people who initiate a service catalog request whenever a comment is added to that request.

·        For checking if an event can be used or not, first it needs to be registered under: “Event Registry”
·        Events can be called from various Server Side operations like: Business Rules, Script Includes or Workflows

·        A Sample script is as below:
if (current.operation() != 'insert' && current.comments.changes()) {
gs.eventQueue("incident.commented", current, gs.getUserID(), gs.getUserName());
}

·        An event when triggered from any of these scripts, can either trigger a notification or execute an event script


The gs.eventQueue function takes the following parameters:


4 comments: