Add attachment to Notification Email
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-14-2016 08:27 AM
I've created a Service Catalog Request which will have an attachment included. Is there a way to include that attachment to Notification Email?
Thanks,
Sarah
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-14-2016 09:07 AM
Hi Sarah
If you like the first approach than yes.
You need to create an email script and then reference the email script using this syntax in your notification record
${mail_script:YOURSCRIPTNAME}
And in the email script table you can create an entry with the following code.
NAME:YOURSCRIPTNAME
SCRIPT:
var gr = new GlideRecord('sys_attachment');
gr.addQuery('table_sys_id',current.sys_id);
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');
}
More info can be found here
Scripting for Email Notifications - ServiceNow Wiki
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-14-2016 10:18 AM
Thanks.
I was able to add the link to the notification, but when I click on the link to open it, it states "This page can't be displayed"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-15-2016 08:59 AM
Hi Sarah
This seems strange can i suggest you to test if you can download an attachment from you instance
https://YOUR_INSTANCE_NAME.service-now.com/sys_attachment.do?sys_id=YOUR_FILE_SYS_ID
Let me know if this is works for you
Cheers
Robo
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-15-2016 09:02 AM
I actually changed the Notification Email Script to the following and it worked!
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("<br><br>Attachments:</br> ");
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 + " ");
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-15-2016 09:15 AM
Hi Sarah
In theory is exactly the same thing. I mean the final result.
At least the initial suggestion was the right thing
Cheers
Robo