Email notification is not working using email script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2023 12:21 AM
I am trying to add group on email notification using email script. but it is not sending notification to group members.
Please refer the code and suggest me :
(function runMailScript(current, template, email, email_action, event) {
var ritm = new GlideRecord('sc_req_item');
ritm.addQuery("request", current.request.sys_id);
ritm.query();
if (ritm.next()) {
var loc = current.u_item_for.location.name; //user location
gs.log("xyz" + loc);
}
var emails = [];
var userName = [];
var gr = new GlideRecord('sys_user_grmember');
if (loc.includes('Operations') && loc.slice(-2) == 'MA') { //if users location contain Operations and Ma notification goes to ServiceNow.Application.Approver.Metrc.MAGrowCompliance group.
gr.addQuery("group.name", "ServiceNow.Application.Approver.Metrc.MAGrowCompliance");
gr.query();
while (gr.next()) {
emails.push(gr.user.email.toString());
userName.push(gr.user.toString());
email.addAddress("cc", gr.user.email.toString(), gr.user.getDisplayValue());
gs.info("Tanuj" + emails.toString());
gs.info("Mahesh" + userName.toString());
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2023 02:30 AM
@Upender Kumar : Tried this solution but still it is not sending email notification
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2023 02:24 AM
are you sure the user you are adding in CC is
1) active and not locked out
2) has email field populated in user record
3) notification preference is enabled