Trigger Notification from gs.eventQueueScheduled
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā02-23-2025 04:05 AM
How can I add more than 2 recipients in gs.eventQueueScheduled for triggering notification ?
I want to send the notification for 3 users using this scheduled event
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā02-23-2025 05:16 AM
Hi @eyal abu hamad , you can pass comma separated sys ids of your recipients as the event parameter.
var users = [];
var user = new GlideRecord("sys_user");
user.addEncodedQuery('active=true');
user.query();
while (user.next()) {
users.push(user.getValue('sys_id'));
}
users = users.join(',');
gs.eventQueueScheduled("test.notify", user, users);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā02-23-2025 09:10 AM
Hi @eyal abu hamad,
In ServiceNow, gs.eventQueueScheduled allows you to trigger events and send notifications. By default, it supports only two parameters for recipient-related values. However, you can send notifications to multiple users by following these methods:
1. Use a comma-separated string for multiple recipients
gs.eventQueueScheduled('your.event.name', current, 'user1@example.com,user2@example.com,user3@example.com', '');
2. Use a Group (Recommended for multiple recipients)
3. Use multiple eventQueue calls
If the above methods do not work, trigger multiple events separately for each recipient:
gs.eventQueueScheduled('your.event.name', current, 'user1@example.com', '');
gs.eventQueueScheduled('your.event.name', current, 'user2@example.com', '');
gs.eventQueueScheduled('your.event.name', current, 'user3@example.com', '');
If this answer helped you, please mark it as helpful so others can benefit too!
Thank you,
Ananya.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā02-23-2025 07:11 PM
you can include multiple recipients by adding comma separated values
var users = 'userSysId1,userSysId2';
gs.eventQueueScheduled("eventName", glideRecordObject, users);
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
⨠Certified Technical Architect || ⨠9x ServiceNow MVP || ⨠ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā02-23-2025 07:12 PM
You can pass multiple recipients as a comma-separated list of Sys IDs in the event parameters, and then configure the notification to use that parameter.
var recipientList = 'user_sys_id_1,user_sys_id_2,user_sys_id_3';
gs.eventQueueScheduled(
'custom.notification.event', // Event name
current, // Target record (e.g., incident, task)
recipientList, // Parm1: List of recipients
'' // Parm2 (optional)
);
Please mark correct/helpful if this helps you!