Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Trigger Notification from gs.eventQueueScheduled

eyal abu hamad
Mega Sage

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

4 REPLIES 4

GopikaP
Mega Sage

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);

Singha8
Tera Expert

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.

 

 

Ankur Bawiskar
Tera Patron
Tera Patron

@eyal abu hamad 

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.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

sunil maddheshi
Tera Guru

@eyal abu hamad 

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!