How to include attachment in Approval notification email
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2020 04:22 AM
Hi
When a user raises a request item in the catalog, they have to attach a document to this, and when they submit the form it sends off an approval email. How can I get this document attached to the approval email that sends off?
Thanks
James

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2020 04:27 AM
Hello,
you can try this code
If the attachment is uploaded on requested item, you don't need getTaskId(). I assume your notification is created on the Approvals table (sys_approval_approver). Change the following line in the above code and I think you should be all set.
var gr = new GlideRecord('sys_attachment');
gr.addQuery('table_sys_id', current.sysapproval.sys_id); // current.sysapproval field should have the requested item object.
gr.query();
Mark it Correct/Helpful if it Helps you

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2020 04:29 AM
Use this script in BR(Approval table)
getAttachment();
function getAttachment()
{
var attachment = new GlideRecord('sc_req_item');
attachment .addQuery('sys_id', current.sysapproval);
attachment .query();
while(attachment .next()) {
GlideSysAttachment.copy("sc_req_item", attachment .sys_id, "sysapproval_approver", current.sys_id);
}
}
Harish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2020 04:30 AM
Hi
If you're using an email notification to send the email, you can check the "Include Attachments" checkbox on the notification, and it'll automatically include all the attachments of the current context record to the email.
Thanks & Regards,
Rishabh Jha
Aavenir (https://www.aavenir.com/)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2020 04:31 AM
Hi James,
Does this needs to be sent only for specific approval records or for all scenarios of approval record?
If there is a need for all approval notifications then you can simply use the Include Attachments checkbox available at each notification level. You can find that in the What it will contains tab of the notification
If this needs to be specific then you can create a mail script as below from System Notificaiton >> Email >> Notification Email script named: getattachments
(function runMailScript(current, template, email, email_action, event) {
var gr = new GlideRecord('sys_attachment');
gr.addQuery('table_sys_id', current.sysapproval);
//gr.addQuery(''); //apply additional query here to restrict it to specific approval records
gr.query();
while (gr.next()) {
template.print('Attachments: <a href="http://' + gs.getProperty("instance_name") + '.service-now.com/sys_attachment.do?sys_id=' + gr.sys_id + '">' + gr.file_name + '</a>\n');
}
})(current, template, email, email_action, event);
Then call the mail script in the notification body in format
${mail_script:getattachments}