How to send email notification with physical attachment

Rameshnathan
Tera Expert

How to send email notification with physical attachment

I have used this below script in email script notification, but its sending the attachment as link but i want to send real  attachment in email please guide me how to do

notification

var eve = "93e903b1db505700d7fa5040cf9619e4";
var gr =new GlideRecord('sys_attachment');
gr.addQuery('sys_id','IN',eve);
gr.query();
while(gr.next()){
template.print('Attachment: <a href="http://'+gs.getProperty("instance_name")+'.service-now.com/sys_attachment.do?sys_id='+ gr.sys_id + '">' + gr.file_name + '</a>\n');
}

22 REPLIES 22

Allen Andreas
Administrator
Administrator

Please see this link: https://community.servicenow.com/community?id=community_question&sys_id=23a00765db98dbc01dcaf3231f96...


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Rajesh Mushke
Mega Sage
Mega Sage

Hey Rameshnathan,

 

you need to create email script with below script:

 

attachLinks();
function attachLinks() {

var gr = new GlideRecord('sys_attachment');


gr.addQuery('table_sys_id',current.sys_id);


gr.query();


if (gr.hasNext()) {


template.print("Attachments: <br />");


while (gr.next()) {


var attachLink = '<a href="' + gs.generateURL(gr.getTableName(),gr.sys_id) + '">' + gr.file_name + '</a>';


template.print(attachLink + "<br />");
}
template.print("<hr/>");
}
}

 

Let me know if you need more help.

 

Thanks,

Rajashekhar Mushke

Community Leader - 18



Thanks,
Rajashekhar Mushke
Rising star : 2022 - 2024
Community Leader -2018
Connect me on LinkedIn : Rajashekhar Mushke

Kia ora Rajashekhar,

Thanks for the contribution above, people like you make this community and system so much better. Since you gave such an excellent answer I'm wondering if you know how to do something similar but different.

It looks like the above script is for pulling attachments on the current record and including them. We are trying to upload a document to Service Now somewhere and then set up a notification which attaches the actual document (not a link to the document).

Do you know if this is possible?

Thanks,

Brett

 

Brian Lancaster
Tera Sage

Is the attachment on the record in the table that your notification is associated with?