Include attachment from Request in OOTB Approval Email

David2001
Tera Contributor

I have a catalog item with attachments enabled, and I want to be able to include those attachments in the OOTB Approval Email. I want to do this without using the 'Include attachments' checkbox in the 'What it will contain' tab on the Notification. Since I only want to do this for a few catalog items and not all.

3 REPLIES 3

Sohithanjan G
Kilo Sage
Kilo Sage

Hi @David2001 

 

You can find the solution here. 

 

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

SohithanjanG_0-1709968409281.png

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}

 

 

Please mark as Accepted Solution if this solves your query and HIT Helpful if you find my answer helped you. This will help other community mates too..:)

I enabled the Include Attachments checkbox but it still doesn't include the attachments in the emails sent.

Sumanth16
Kilo Patron

Hi @David2001 ,

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}

 

 

If I could help you with your Query then, please hit the Thumb Icon and mark it as Correct !!

 

Thanks & Regards,

Sumanth Meda