- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2024 12:26 AM
Hi,
I have a requirement to send an email notification to all assignment group's users of the child incidents when the parent incident is closed.
I created a Business rule on the incident table that trigger when state changes to close. then I go and check if this incident has child incidents with assignment group field is not empty. If yes, I know that I need to use the command:
gs.eventQueue();
what should I pass inside () ?
In addition, when creating the notifcation do I need to populate something in the 'Who will receive' Tab or not because I will specify the it inside the gs.queue?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2024 02:06 AM - edited 07-22-2024 02:08 AM
Hello @Alon Grod ,
gs.eventQueue() takes five parameter and one of them is optional.
gs.eventQueue('event_name','glide_record_object',parm1,parm2, 'queue_name');
//#5 is optional
If you already know to whom you want to send notification then, you can directly pass the mail_id of that group in #parm1 and set the receiver as EVENT PARM 1 or you can select the group in the who will receive it tab as follows -
If my answer solves your issue, please mark it as Accepted✔️ and Helpful👍!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2024 01:34 AM
Hi @Alon Grod,
You won't get much better advice than from the man himself, @Chuck Tomasi. Check out his video which walks you through how and where to use gs.eventQueue().
High level steps:
- Create the event
- Call the event using gs.eventQueue() in a Business Rule as you've explained
- Set up a Notification which is triggered from said event
Chuck goes over it in the below link.
To help others (or for me to help you more directly), please mark this response correct by clicking on Accept as Solution and/or Kudos.
Thanks, Robbie
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2024 01:46 AM
Hi @Alon Grod
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('x_60157_employee_spe.employeeOccasion',current,current.number,gs.getUserName());
Regards,
Amit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2024 01:56 AM - edited 07-22-2024 01:57 AM
Notifications triggered from events are still associated with a record in the same way that condition based notifications are, so you can specify the recipients using 'Users/Groups in fields' like you usually would
I've not watched the youtube video that's been added as a response so this will likely do into more detail but the second argument in gs.eventQueue([event name],[this one]) is the GlideRecord object of the record that the event relates to but there are 3 additional optional arguments that can be added
Depending on where your Business Rule triggered event is located:
- On the parent incident (as you've mentioned above), the GlideRecord object would need to be each of the child incidents, so you would effectively be triggering this event multiple times based on the number of child incidents
- On the child incident, you could pass in current directly
This is documented on GlideSystem - Global (servicenow.com) (Search for eventqueue)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2024 01:59 AM
Hi @Alon Grod ,
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.
gs.eventQueue('name.of.event', current, parm1, parm2);
Breakdown:
'name.of.event' will be the event name created under Event > registry [sysevent_register].
current is the GlideRecord object
In parm1 or parm2 you can pass recipient(s)
Now, in the notification, under when to send, you will select 'fired by event' and provide the correct event name which you created in sysevent_register table in above steps. Once that is done, navigate to 'Who will receive' there will be 2 checkbox named 'Event parm 1 contains recipient' and 'Event parm 2 contains recipient' so based on the parameter you paased in gs.eventQueue() in business rule, you have to check this box in notification.
Check the post which you give you more insights:
Video: Community Live Stream - API Adventures - gs.eventQueue
The Power of #ServiceNow System Events
ServiceNow Events | ServiceNow trigger Email notification from Event
Mark this as Helpful / Accept the Solution if this helps
Mark this as Helpful / Accept the Solution if this helps.