gs.eventQueue() method is used to trigger events programmatically. These events are defined in the Event Registry and you can associate with notifications, scripts, or other custom actions. It allows you to execute asynchronous tasks in ServiceNow.
The name of the event to trigger, as defined in the Event Registry (sysevent).
Yes
record
The GlideRecord of the table where the event is associated (context record for the event).
Yes
parm1
(Optional) Parameter 1 to pass to the event. Commonly used in event scripts.
No
parm2
(Optional) Parameter 2 to pass to the event. Commonly used in event scripts.
No
eventQueue
(Optional) A custom event queue name. If not provided, the default event queue is used (default).
No
gs.eventQueue() Method
The eventQueue() method is part of the GlideSystem server-side API. 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:
Event name. Enclose the event name in quotes.
GlideRecord object, typically current but can be any GlideRecord object from the event’s table.
Any value that resolves to a string. This is known as parm1 (Parameter 1). Can be a string, variable that resolves to a string, or method that resolves to a string.
Any value that resolves to a string. This is known as parm2 (Parameter 2). Can be a string, variable that resolves to a string, or method that resolves to a string.
(Optional) Name of the queue to manage the event.
example:
gs.eventQueue(‘event.name’, GlideRecord, parm1, parm2); // standard form