- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-04-2016 09:30 AM
I've built a way to notify approver delegates whenever their delegator has a new approval request, so I thought I would share it here. I used another post that did something very similar and just modified it to do what I wanted. I know the delegation option lets you specify someone as an Approval delegate but that by itself doesn't notify them when they have a new approval request. There is also the option to CC Notifications but that sends them every single notification intended for the delegator and not strictly the approval notifications. There wasn't a middle ground. I needed a way to only send approval delegates the approval notifications. Here's what I did:
1. Create a new email script with the following code:
// Add delegates to an approval email
var delegate = new GlideRecord('sys_user_delegate');
delegate.addQuery('user',current.approver.sys_id);
delegate.addQuery('starts','<=',gs.nowNoTZ());
delegate.addQuery('ends','>=',gs.nowNoTZ());
delegate.addQuery('approvals','true');
delegate.query();
while (delegate.next()) {
// get the email address of the delegate if they have notification enabled
var usr = new GlideRecord('sys_user');
usr.addQuery('sys_id',delegate.delegate);
usr.addQuery('notification','2');
usr.addQuery('active','true');
usr.query();
while (usr.next()) {
// add the delegate's email to the "cc" list
email.addAddress("cc", usr.email, usr.name);
}
}
2. Reference this script within the email templates used by your approval notifications, like this:
${mail_script:approval_delegate_cc}
This will allow your delegates to get approval emails for the delegator without getting all the noise of the delegator's other emails. It does not require any special configuration within the delegation record other than enabling the Approvals option. Additionally, if the delegate disables their own email notifications or if the delegate is deactivated this email will be suppressed. This feature will come in handy for requester users who do not have full UI access to perform approvals but are setup as delegates. This way they get emails for the approvals and can approve via email.
Solved! Go to Solution.
- 3,768 Views
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-16-2016 03:08 PM
This was exactly what we needed - thank you so much for sharing! It worked like a champ.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-10-2018 01:49 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-11-2018 07:14 AM
Tricia,
I can't see any significant differences in what you have from what I have. The only slight difference is that in my template I don't actually have any Message HTML content. We just put it all in the Message field instead. You might try putting the ${mail_script:approval_delegate_cc} in the Message section as well to see if that helps.
Chad