Add a specific file in a notification

Diana Yazmin
Tera Contributor

Hi experts,

 

A notification has been created with the configuration to include attachments, the problem is that only 1 specific file that our fulfiller will place in the task is required to travel in the notification, not all of them. This is possible?

 

Thank you

2 REPLIES 2

Amit Verma
Kilo Patron
Kilo Patron

Hi @Diana Yazmin 

 

Yes, it is. Please refer below blogs for reference :

https://www.servicenow.com/community/developer-forum/need-to-send-just-1-attachment-or-a-few/m-p/145...

https://www.servicenow.com/community/developer-blog/tnt-attaching-shared-documents-to-an-email-notif...

 

Thanks & Regards

Amit Verma


Please mark this response as correct and helpful if it assisted you with your question.

Harish KM
Kilo Patron
Kilo Patron

HI @Diana Yazmin you can create a notification email script like below, and pass the file name . Call this email script inside your notification to attach the attachment.

script:

attachLinks();
function attachLinks() {

var gr = new GlideRecord('sys_attachment');
gr.addQuery('table_sys_id',current.sys_id);
gr.addQuery('file_name',"");// pass the file name here
gr.query();
if(gr.hasNext()){
template.print('Attachments: \n');
while (gr.next()) {
var attachLink = '<a href="' + gs.getProperty("glide.servlet.uri") + gs.generateURL(gr.getTableName(),gr.sys_id) + '">' + gr.file_name + '</a>';
template.print(attachLink + '\n');
}
template.print('<hr/>');
}
}
Regards
Harish