- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-15-2017 01:36 AM
Hi All,
I am trying to create an notification email when there are new comments added during the approval process. I can make the email send to send event creator and the approver. However we have multiple approver and would like the email notify all of them. Would like to know how would I do it?
I am trying to use the email script and include it in the email but it never works. Would an expert review anything goes wrong?
Thanks,
Wai
*****************************************************************************************************
(function runMailScript(current, template, email, email_action, event) {
// Add your code here
var friends = new GlideRecord('sysapproval_approver');
friends.addQuery('sysapproval', current.sysapproval);
friends.query();
while(friends.next()) {
if (friends.approver.toString() != current.approver.toString()) {
addAddress("CC",friends.approver.email, friends.approver.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
‎06-15-2017 02:22 AM
Hi Wai,
You have to add email.addAddress() instead of just addAddress()
(function runMailScript(current, template, email, email_action, event) {
// Add your code here
var friends = new GlideRecord('sysapproval_approver');
friends.addQuery('sysapproval', current.sysapproval);
friends.query();
while(friends.next()) {
if (friends.approver.toString() != current.approver.toString()) {
email.addAddress("CC",friends.approver.email, friends.approver.toString());
}
}
})(current, template, email, email_action, event);
Regards
Swamy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-15-2017 02:14 AM
addAddress("CC",friends.approver.email, friends.approver.toString()); email object is missing here
try email.addAddress("CC",friends.approver.email, friends.approver.toString());
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-15-2017 02:22 AM
Hi Wai,
You have to add email.addAddress() instead of just addAddress()
(function runMailScript(current, template, email, email_action, event) {
// Add your code here
var friends = new GlideRecord('sysapproval_approver');
friends.addQuery('sysapproval', current.sysapproval);
friends.query();
while(friends.next()) {
if (friends.approver.toString() != current.approver.toString()) {
email.addAddress("CC",friends.approver.email, friends.approver.toString());
}
}
})(current, template, email, email_action, event);
Regards
Swamy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-15-2017 03:00 AM
Hi Swamy,
Thanks for your reply. You point out the main point. Now my code like below and it works!
(function runMailScript(current, template, email, email_action, event) {
// Add your code here
var friends = new GlideRecord('sysapproval_approver');
friends.addQuery('sysapproval', current.sysapproval);
friends.query();
while(friends.next()) {
if (friends.approver.toString() != current.approver.toString()) {
email.addAddress("cc",friends.approver.email, friends.approver.name);
}
template.print('TEST END');
}
})(current, template, email, email_action, event);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-19-2020 07:24 AM
not working