- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2023 06:54 AM
Hello,
I want to create a link on email body and when user links on that link word file need to download, I am trying to include email script in the body but the it's not working. Can someone please suggest the way to achieve it.
Thanks,
Prudhvi
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2023 07:06 AM
Hello @Prudhvi Raj4
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>');
Regards,
Shyamkumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2023 07:23 AM
Yes, I am doing the same but its not showing up the link on email, Do we need to load the attachment to sys_attachment table before if so how to load it which will work for the tasks?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2023 07:06 AM
Hello @Prudhvi Raj4
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>');
Regards,
Shyamkumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2023 07:23 AM
Yes, I am doing the same but its not showing up the link on email, Do we need to load the attachment to sys_attachment table before if so how to load it which will work for the tasks?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2023 07:26 AM - edited 01-05-2023 07:34 AM
yes attachment should exists in sys_attachment table in order to download
Regards,
Shyamkumar