- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
on 11-29-2018 05:29 AM
Hi
You can use the below code to attach any attachments to email notifications, just open email scripts and add the code. Make sure to add the email script in your notification as ${mail_script:<name of your email script>}
var gr =new GlideRecord('sys_attachment');
gr.addQuery('table_sys_id',current.sys_id;
gr.query();
while(gr.next()){
template.print('Click on the link to download : <a href="https://'+gs.getProperty("instance_name")+'.service-now.com/sys_attachment.do?sys_id='+ gr.sys_id+'">'+ gr.file_name+'</a>');
}
}
the above code will create links for all the attachments present.
If you have attachment in some other table say in the approver records then use the below code :
printattachments();
gs.log("SYSID: "+current.sys_id);
function printattachments(){
var d_id="";
var apr= new GlideRecord("sysapproval_approver");
apr.addQuery('sysapproval',current.sys_id);
apr.query();
if(apr.next()){
d_id=apr.sys_id;
gs.log("SYSID approver: "+d_id);
// console.log("SYS ID: "+d_id);
}
var gr =new GlideRecord('sys_attachment');
gr.addQuery('table_sys_id',d_id);
gr.query();
while(gr.next()){
template.print('Click on the link to download : <a href="https://'+gs.getProperty("instance_name")+'.service-now.com/sys_attachment.do?sys_id='+ gr.sys_id+'">'+ gr.file_name+'</a>');
}
}
Thanks
SIddhant.
- 4,583 Views
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
The script to create links for all attachments in a record works fine for my case. Thank you very much for sharing this.
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
When you are printing the link you need to make the following changes:
template.print('Click on the link to download : <a href="https://'+gs.getProperty("instance_name")+'.service-now.com/sys_attachment.do?sys_id='+ gr.sys_id"</a>');
