- 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 05:44 AM
Hi sathwik
yes you can pass the values from parameter and add those users in cc
email.addAdddress("cc",event.param2);
if this is nit what you are looking for then provide more details on how you are passing param2 values.
Example scripting for email notifications
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
5x ServiceNow MVP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-14-2022 06:00 AM
Hi, from schedule script..
in event parm2 I am already passing some mail ids.. along with that I need to some more mail id;s but those needs to send mail in CC
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-14-2022 06:28 AM
Hi sathwik
you can concat it in param2 with a seperator(maybe # or %...) and split it in your email_script.
var cc = event.param2.toString().split("#");
can you share scheduled job logic.
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
5x ServiceNow MVP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-14-2022 09:52 AM
var assigneeArr = [];
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());
}
var uniqueAssignees = new global.ArrayUtil().unique(assigneeArr);
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]);
}
}
gs.eventQueue('x_408194_loading_e.incident.over30days', gr, incidents.toString(), getEmail[i]);
}
Email Script
(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */
email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */
event) {
var gr = new GlideRecord("x_408194_loading_e_scoped_data_table");
gr.addEncodedQuery("sys_idIN" + event.parm1.toString());
gr.query();
while (gr.next()) {
var getCCId = gr.id2;
var getEmail = new GlideRecord('sys_user');
getEmail.addQuery('user_name', getEmail);
getEmail.query();
if (getEmail.next()) {
email.addAddress("cc", getEmail.name, getEmail.email);
template.print(getEmail.name);
template.print(gr.number);
template.print('\n');
template.print('\n');
} }
})(current, template, email, email_action, event);
In email script, I have written email.address, those needs to pass in event parm2