- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
There is a requirement to trigger an email notification to the Business Application Owner when an incident is resolved. To fulfill this requirement, I developed a Mail Script and included log statements to verify that the script is executing as expected.
Based on the system logs, I can confirm that the script is running and that the email address is being retrieved correctly. However, despite this confirmation, the email notification is not being sent to the Business Application Ownerand user is active
The current Mail Script is provided below for reference:
if (!current.u_application)
return;
var appGR = new GlideRecord('cmdb_ci_business_app');
appGR.addQuery('sys_id', 'IN', current.u_application);
appGR.query();
gs.info('Mail script triggered for Sev1/Sev2 incident.');
while (appGR.next()) {
var ownerGR = appGR.u_it_system_owner.getRefRecord();
email.addAddress("to", ownerGR.email.toString(), ownerGR.email.toString());
gs.info('Owner email: ' + ownerGR.email.toString());
}
})(current, template, email, email_action, event);
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
then do this
1) use "Lookup Records" on cmdb_ci_business_app with condition as Sys ID [IS ONE OF] INC.u_application
2) then use "For Each" to iterate those records and then use "Send Email" flow action and pick owner of respective Business App
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
you can't set the TO i.e. recipient via email script
Why not use Flow Designer for this
1) flow triggers when INC is resolved
2) then use "Send Email" flow action and set the recipient as App owner by dot walking your u_application field
For example I am picking Assigned to from Service field
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @Ankur Bawiskar
Thanks for your response,
u_application is of list type not reference type, so unable to dot walk to the trigger the mail to app owner
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
then do this
1) use "Lookup Records" on cmdb_ci_business_app with condition as Sys ID [IS ONE OF] INC.u_application
2) then use "For Each" to iterate those records and then use "Send Email" flow action and pick owner of respective Business App
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Thank you @Ankur Bawiskar , it is working
