- 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-2020 12:41 PM
Ricardo, I lost many hours debugging a situation many years ago where I was pushing data into an array and it wasn't working correctly. Issue ended up being a pointer issue within memory of processing the code and my array basically had the same value over and over again. Adding + "" forces the code to refresh the data to prevent the above issue from happening.
But you will find the following methods do the same. Will use the example above:
userList.push(userRec.sys_id + "");
userList.push(userRec.sys_id.toString());
userList.push(userRec.getValue("sys_id"));
For SysIDs the first two methods are fine since the data is a string, but if the value is say a date, using getValue() is the best. I have personally started using getValue() as my default method.
Please learn from my mistake and always include one of the above methods when pushing data into an array.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2024 11:12 AM
What if you want to build a list of email address from another table other than sys_user? Is it just a comma delimited string of email addresses?