- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-22-2016 02:50 PM
Hi How do i pass multiple recipients in parm1 parameters for the eventQueue? is it really necessary to pass the name of the recipient in parm2? Any ideas would be greatly appreciated. Thanks
var rec;
var nm;
var sIncl = new PIRGlobal();
var isRMPM = sIncl.isRMPM();
if(isRMPM){
rec = current.opened_by;
nm = current.opened_by.name;
}else{
rec = current.u_gatekeeper;
nm = current.u_gatekeeper.name;
}
gs.log('rec= '+rec+' nm= '+nm);
//added by Regina: Event to be used in sending notifications for Cancelled PIRs
gs.eventQueue("pir.cancel.request", current,rec,nm);
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-22-2016 03:07 PM
Regina,
You can pass multiple values separated by a comma. The email notifications just need a comma separated list of user sys_id's and you don't need to pass the name unless you want them to show up in the email to line. If you don't pass it, then just the email address will be present. Here is some example code to get a list of users and create an array that you can then pass to an event:
var userList = [];
var userRec = new GlideRecord("sys_user");
userRec.addEncodedQuery(YOUR-ENCODED-QUERY);
userRec.query();
while (userRec.next()) {
if (userList.toString().indexOf(userRec.sys_id) == -1) {
userList.push(userRec.sys_id + "");
}
}
gs.eventQueue("EVENT-NAME", current, userList.toString());
In my example code, emails will be in parm1

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-22-2016 02:57 PM
Hi Regina,
You could json encode an object and pass it in the parameter, then use a mail script in the notification to set the addresses.
Mini-Lab - Events: Passing Objects
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-22-2016 03:07 PM
Regina,
You can pass multiple values separated by a comma. The email notifications just need a comma separated list of user sys_id's and you don't need to pass the name unless you want them to show up in the email to line. If you don't pass it, then just the email address will be present. Here is some example code to get a list of users and create an array that you can then pass to an event:
var userList = [];
var userRec = new GlideRecord("sys_user");
userRec.addEncodedQuery(YOUR-ENCODED-QUERY);
userRec.query();
while (userRec.next()) {
if (userList.toString().indexOf(userRec.sys_id) == -1) {
userList.push(userRec.sys_id + "");
}
}
gs.eventQueue("EVENT-NAME", current, userList.toString());
In my example code, emails will be in parm1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-22-2016 03:19 PM
Worked like a charm. Thanks Michael!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-22-2020 07:40 AM
Hi Michael,
Why is needed to add the + "" when you are creating the array?
Thanks