- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2022 12:02 AM
Hello
I need help. I am creating a notification template. I would like to add the download link of "Add attachments" of record producer. How to?
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2022 12:24 AM
Hi Author,
Try the below notification script and call it into the email body
attachLinks();
function attachLinks() {
//Check for any attachments and add attachment links if they exist
var gr = new GlideRecord('sys_attachment');
gr.addQuery('table_sys_id',current.sys_id);
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/>');
}
}
If there are multiple attachments try the below in email script to download all of them in a ZIP file
template.print('Click on the link to download : <a href="https://'+gs.getProperty("instance_name")+'.service-now.com/download_all_attachments.do?sysparm_sys_id='+ current.sys_id+'">'+Attachments+'</a>');

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2022 12:11 AM
Hi,
Please check below link:
Use email script to add attachment links, you can refer above links for email script examples.
Thanks,
Anil Lande
Thanks
Anil Lande
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2022 12:24 AM
Hi Author,
Try the below notification script and call it into the email body
attachLinks();
function attachLinks() {
//Check for any attachments and add attachment links if they exist
var gr = new GlideRecord('sys_attachment');
gr.addQuery('table_sys_id',current.sys_id);
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/>');
}
}
If there are multiple attachments try the below in email script to download all of them in a ZIP file
template.print('Click on the link to download : <a href="https://'+gs.getProperty("instance_name")+'.service-now.com/download_all_attachments.do?sysparm_sys_id='+ current.sys_id+'">'+Attachments+'</a>');