How to embed an attachment from a catalog item within an email notification?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-13-2016 11:14 AM
I have created a catalog item and on the back end have attached 2 documents that are now in the sys_attachment table. I want these two attachments to be sent within an email each time it is fired (the email is part of my workflow for the catalog item). I don't want it to exist as a link; as this code that I've been using on an Email script does:
printattachments();
function printattachments() {
var gr = new GlideRecord('sys_attachment');
gr.addQuery('table_sys_id','');
gr.query();
while (gr.next()) {
template.print('Attachment: <a href="https://' + gs.getProperty("instance_name") + '.service-now.com/sys_attachment.do?sys_id=' + gr.sys_id + '">' + gr.file_name + '</a>');
}
}
I want the attachments to actually appear as attachments within the email. I saw on the wiki that you can use the
GlideSysAttachment.copy('sourcetable', 'sys_id', 'destinationtable', 'sys_id');
script, but I don't know what to put in for the 'destinationtable' and the 'sys_id' that follows that. The attachments do exist in the 'sys_attachment' table so I'm assuming that would go in the sourcetable part, but still don't know what to put in the 'sys_id' part. I also have no idea if this should be an email script or something else.
Thoughts?
Thanks!
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-13-2016 11:20 AM
Looking to see what I can find...
in the mean time, that Wiki article you got was a bit out of date. You don't need the https:// instance name garbage any more. The system is smart enough to analyze and auto-correct URLs. The template.print line would look more like this today:
template.print('Attachment: <a href="'/sys_attachment.do?sys_id=' + gr.sys_id + '">' + gr.file_name + '</a>');
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-18-2016 06:56 AM
Okay thanks! But I'm still looking to embed the attachment within the email. Not link it. Any ideas on this?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-18-2016 06:58 AM
Hi Tagwa,
Nothing yet. All the references I seem to find suggest this is not a very good idea as the attachments may be too big for the receiving email server to accept and could be stripped off if it is not the right file type.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-18-2016 07:08 AM