- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2019 08:31 PM
- 108,916 Views
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2019 08:35 PM
Generating Events
There are two ways to generate events:
- Server-side script using the gs.eventQueue() method
- Workflow Create Event activity
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
gs.eventQueue('x_58872_needit.overdueNeedItTask',current,current.number,gs.getUserName());
you can refer below links:
after going throw this mark it as correct/helpfull.
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2019 08:35 PM
Generating Events
There are two ways to generate events:
- Server-side script using the gs.eventQueue() method
- Workflow Create Event activity
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
gs.eventQueue('x_58872_needit.overdueNeedItTask',current,current.number,gs.getUserName());
you can refer below links:
after going throw this mark it as correct/helpfull.
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2019 08:37 PM
Hi,
Please refer to the official documentation with an example in here: https://docs.servicenow.com/bundle/madrid-platform-administration/page/administer/platform-events/ta...
Events are used to execute server side operations like sending notifications or executing any scripts asynchronously at the backend.
gs.eventQueue(event name, record, parm 1, parm 2) is used initiate an event calls, It has following parameters to passed in it: Event name, Current object of record, Parmeter 1 to pass, Parameter 2 to pass. It can be called in any server side scripts like business rules, workflow, script includes etc
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2019 08:39 PM
Hi Elizabeth,
gs.eventqueue is used to trigger an event.This is used in server side.
eventQueue(String name, Object glideRecord, String parm1, String parm2, String queue)
Parameter(s):
Name | Type | Description |
---|---|---|
name | String | Name of the event being queued. |
glideRecord | Object | GlideRecord object, such as "current". |
parm1 | String | (Optional) Saved with the instance if specified. |
parm2 | String | (Optional) Saved with the instance if specified. |
queue | String | Name of the queue. |
The first parameter is event name and this is defined in the event-> Registry.
Please mark your response helpful or correct.
Thanks,
CB
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2024 12:53 AM
The gs.eventQueue is a method in ServiceNow that is used to fire an event. This method is typically used in server-side scripting.
Here's a summary of its usage:
- The gs.eventQueue method is used to trigger an event in ServiceNow.
- It is a server-side method, meaning it is used in server-side scripts like Business Rules, Script Includes, etc.
- The syntax for using gs.eventQueue is: gs.eventQueue(String eventName, GlideRecord gr, String parm1, String parm2)
- eventName: The name of the event to be fired.
- gr: The GlideRecord of the record that the event is associated with.
- parm1 and parm2: Optional parameters that can be passed to the event.
- The event that is triggered by gs.eventQueue can be handled by an Event Script or a Notification.
- This method is asynchronous, meaning the script will continue to run without waiting for the event to complete.
Here's a sample code snippet:
javascript
var gr = new GlideRecord('incident');
gr.get('incident_number', 'INC0010001');
gs.eventQueue('custom.event', gr, 'parameter1', 'parameter2');
In this example, a custom event named 'custom.event' is fired for the incident with number 'INC0010001', and two parameters 'parameter1' and 'parameter2' are passed to the event.
nowKB.com