- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-14-2022 04:16 AM
I am passing some email ids through event param2, and I want to add some more email ids in CC.. is it possible?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-14-2022 11:08 PM
Ok Got it,
Since we cannot set TO address from script, pass these values as param1 (modify notification to include param1 as recipents)
For parameter2, try this
create a json and pass incidents,cc address values.
var assigneeArr = [];
var assigneeArrr=[];
var incidentArr = [];
var getEmail = [];
var gr = new GlideRecord("x_408194_loading_e_scoped_data_table");
gr.query();
while (gr.next()) {
incidentArr.push(gr.sys_id.toString());
assigneeArr.push(gr.id.toString());
assigneeArrr.push(gr.id2.toString());
}
var uniqueAssignees = new global.ArrayUtil().unique(assigneeArr);
var uniqueAssigneees = new global.ArrayUtil().unique(assigneeArrr);
gs.info("Unique TO Users " +uniqueAssignees);
gs.info("Unique CC Users " +uniqueAssigneees);
for (var i = 0; i < uniqueAssignees.length; i++) {
var incidents = [];
for (var j = 0; j < assigneeArr.length; j++) {
if (uniqueAssignees[i] == assigneeArr[j]) {
var gr2 = new GlideRecord('sys_user');
gr2.addQuery('user_name', assigneeArr[j]);
gr2.query();
if (gr2.next()) {
getEmail.push(gr2.email);
}
incidents.push(incidentArr[j]);
}
}
var cc=[];
for ( i = 0; i < uniqueAssigneees.length; i++) {
for ( j = 0; j < assigneeArrr.length; j++) {
if (uniqueAssigneees[i] == assigneeArrr[j]) {
var gr3 = new GlideRecord('sys_user');
gr3.addQuery('user_name', assigneeArrr[j]);
gr3.query();
if (gr3.next()) {
cc.push(gr3.email);
}
}
}
var obj={};
obj['incidents'] = incidents.toString();
obj['cc'] = cc.toString();
gs.info("Get All Email Id's " +getEmail[i]);
gs.eventQueue('x_408194_loading_e.incident.over30days', gr, getEmail, obj);
}
}
In email-script access param2
var cc = event.param2.cc;
var inc = event.param2.incidents
param1 will have TO address, param2 will have both cc and incidents info.
Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-14-2022 11:22 PM
No Sathwik, I am passing incidents info in second paramter from json.
check below part of the code:
var obj={};
obj['incidents'] = incidents.toString();
obj['cc'] = cc.toString();
All the values are passed,
getEmail - as parameter1 (since these are 2 address)
obj - as parameter 2 ( which has both cc and incidents info)
Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-14-2022 11:25 PM
Ohh okay, Got it.. I will try it
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-14-2022 11:38 PM
The concept here is, to send consolidate email.. based on ur code.. It triggers individual email..
that is the reason I am passing sysid of records to email script and triggering wth even parm2
If you see below example, earlier based on my code it trigger 2 emails.. but based on the code you suggested it will trigger 2 emails..
Note : Here id [TO] , id2 [CC]
is there any possibility to store TO and CC users in event parm2 and need to separte after moving to notification email script?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-15-2022 12:00 AM
Code was almost, but event parm1.. was triggering to only one email..last record.. as per above it needs to trigger for two users.. should I write any loop?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-15-2022 12:45 AM
In email script, this part was not working..
Is it the right way to call event parm? I am getting output as "UNDEFINED"
var getCCIds = event.parm2.cc;
gs.info("Get CC Id Details "+getCCIds);