logo

NJP

Generating Events

Import · Jan 12, 2023 · article

There are two ways to generate events:

  1. Server-side script
  2. Workflow Create Event activity

The eventQueue() methods are part of the GlideSystem server-side API. Use the eventQueue() methods to generate events in server-side scripts. The eventQueue() method inserts an event in an event queue. The eventQueue() method is typically passed four parameters but can also take an optional 5th parameter:

  1. Event name. Enclose the event name in quotes.
  2. The GlideRecord object is typically current but can be any GlideRecord object from the event’s table.
  3. Any value that resolves to a string. This is known as parm1 (Parameter 1). It can be a string, a variable that resolves to a string, or a method that resolves to a string.
  4. Any value that resolves to a string. This is known as parm2 (Parameter 2). It can be a string, a variable that resolves to a string, or a method that resolves to a string.
  5. (Optional) Name of the queue to manage the event.

gs.eventQueue method is typically passed four parameters. The logic that responds to an event has access to the passed in GlideRecord object, parm1, and parm2.

For Example:-

gs.eventQueue(‘’,current,current.number,gs.getUserName());

DEVELOPER TIPS:-

Use gs.getUserName() and gs.getUserID() for parm1 and parm2 if no other values are required to see which user triggered the event in the event log.

View original source

https://medium.com/@LearnITbyPrashant/generating-events-f79cb272f015?source=rss-d005fc598f0a------2