- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2018 01:49 PM
I want to understand how to send emails to a list of people, since the OOTB functionality in notifications doesn't fit my use case.
I have a business rule that triggers an event based on a condition for a single department entry which sends a single email notification to the department submitter.
gs.eventQueue("my.UserSubmission", current);
What I want is the notification to go to half a dozen people in the department. Please advise if this is correct.
1) Add a function to my business rule advanced script section that generates a comma separated list of either sys_ids for the users-to-be-notified from the user table or comma separated email addresses for the users-to-be-notified.
fx() = parm1="user1@gmail.com,user2@gmail.com,user3@gmail.com";
or
fx() = parm1="6f20d12b6f82850023bd5965bd3ee001, 6f20d12b6f82850023bd5965bd3ee002,6f20d12b6f82850023bd5965bd3ee003";
2) Pass that to the event via a call, such as,
gs.eventQueue('my.UserSubmission', current, parm1);
3) In the notification make sure the "Event parm 1 contains recipient' box is checked.
Is that right? Or is there anything I've overlooked?
Thank you in advance.
G
PS, bonus questions:
All of which begs the question is there an easy way to get the sys_id's for all users assigned a specific role?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2018 01:56 PM
This all looks correct. As far as getting all users with a specific role, you will need to query for them like this...
var usrArr = [];
var users = new GlideRecord('sys_user_has_role');
users.addQuery('role.name', 'YOUR_ROLE_NAME');
users.query();
while (users.next()) {
usrArr.push(users.getValue(user));
}
// Convert usrArr to string
var usrString = usrArr.join();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2018 01:24 PM
Final function that worked for what I needed:
function getAllUsersInRole (roleName) {
var usrArr = [];
var users = new GlideRecord('sys_user_has_role');
users.addQuery('role.name', roleName);
users.query();
while (users.next()) {
usrArr.push(users.user.email);
}
// Convert usrArr to string
var usrString = usrArr.join();
return usrString;
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2021 10:16 AM
I need to send multiple notifications whenever an asset is going to expire before 30,60,90 days. Here, I have generated seperate notification and business rules for each.
But here in gs.eventQueue(''), I have created only one event registry and can I use that single event registry in all notifications and business rules?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2021 10:16 AM
Please help me out in this,
Thanks in advance