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
‎03-21-2017 12:21 PM
You can check below thread from Jim Coyne which may be useful:
Sending Documents in an Email Notification
Regards,
Shloke
Regards,
Shloke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-21-2017 03:27 PM
Doesn't look like that will accomplish what I need, as the attachment is submitted when the user logs the catalog request. The attachment will end up attached to the RITM automatically at this point, and that is what I need to have emailed out.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-23-2017 11:29 AM
An update... I have changed to using an event and normal email notifications, and had the email notification trigger off of the RITM table, with the "Include attachments" attribute. It's working as expected now.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-18-2016 07:22 AM
Ideally, it should send all the files attached to the record but as ctomasi pointed out, it might be happening because of the size limit of the email.
Try attaching 2 small files and test.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-18-2016 07:24 AM
And yes, all the files needs to be attached to the record for which the email is triggered.