This article is a supplement to the ServiceNow documentation. For full documentation please refer ServiceNow official website
Checkout our NEW Video Channel you can like and subscribe too!

Introduction

Events are an indication in ServiceNow that something notable has occurred. Events can be generated by server-side scripts, workflows, ServiceNow processes, or by user actions such as:

  • Impersonating a user
  • Logging in
  • Viewing a record
  • Modifying a record

Each event is an entry in an event queue and not an action.

Unless logic is created to respond to events, nothing happens with an event after it is generated

Responses can be:

By convention, events are named using the syntax <table name>.. *For example*, incident.updated or problem.closed

1.png

Events are generated using various methods. The most common ways of generating events are by using Business Rules or Workflow Activities. Other advanced methods include triggers from various service Now applications like security operations, Service Mapping and Discovery.

Common way to Create Event

  1. Add event to the Event Registry (not needed if you generate an already registered event).
  2. Generate the event.
  3. Respond to the event. event126thoct.PNG

Scheduled jobs

Periodically read the event queue and forward them to the appropriate handler for processing. The handler uses information from event records to take some kind of action such as:

  • Run a script action
  • Schedule a job
  • Send a notification
  • Trigger a workflow activity
  • Trigger an inactivity monitor

If we are taking any process (Incident process, Change process) and if a particular milestone is reached then we can actually create an event

Event registry

The events registry lists the events the system recognizes. Use registered events to automate other activities, such as script actions or notifications.

Event states

  1. Ready
  2. Processed
  3. Error
  4. Transferred

When an event is rotated, a duplicate record is created in an active shard to be processed. A scheduled job processes the event when it is next in the queue, but it is not possible to predict when this will happen as because several events may need to be processed before it. Therefore, you can reprocess the event.

Event logs

All generated events are put into an event queue. Although there is more than one type of event queue, all generated events are viewable in the Event Log: System Policy > Events> Event Log. Generating an event puts an entry in the Event Queue it is associated with but does not take action beyond that.

The event Log displays the records from the Event[sysevent] table.

Event actions

Events must be responded to in order to take actions:

Script Actions are server side scripts which respond to generate events. Script Actions have the full power of Service Now’s JavaScript API behind them.

Email Notifications (or SMS or Meeting Invitation) send messages to users.

How can we create an event?

  1. Type registry in the left Navigation pane >System policy>Event>registry event226thoct.PNG It shows all the event in the current system.
  2. Click on New Button.Put the event Name Event26102019 (10).png
  3. After fill-up all the fields we will click on Submit button.

How to trigger the particular event?

  1. Left pane type Business rules
  2. Click New button to create a Business rules Event26102019 (11).png Event26102019 (12).png In the advanced Tab we can write a script. In this script we are going to trigger the event. Event26102019 (13).png

The lines in the script trigger the event. We will write the

gs.eventQueue("Event name",argument,"parameter1","parameter2")

where Event name is the Queue name we created earlier argument in the current gliderecord object (e.g incident fields before inserting in a BR) parameter we want to pass, can be empty also

Click on submit button.This is how we can trigger the event.

Two things we can do here

Script Action with the script action what we can do this, If this event is triggered we can run certain script.In script action we can click on new button>we can select the event name and then we can write an script.

If the particular event is triggered then the script will be execute Event26102019 (14).png

Notification Creating / modifying Email Notification:

Event26102019 (15).png Event26102019 (16).png

Learn more about notification here

    Content