Add Variable attachment to notification email
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-24-2025 12:49 PM
Hi,
I'm here after referring
Adding attachments to Email - ServiceNow Community
I'm tring attach dynamic vitiable attachment attached during form submission to OOB approval email notification. below is my After insert BR on sys_email table. But it isn't working. could anyone please help me.
(function executeRule(current, previous /*null when async*/) {
// Get the approval record (sysapproval_approver)
var approverGR = new GlideRecord(current.target_table);
if (!approverGR.get(current.instance))
return;
var catItem = ritm.cat_item.getRefRecord();
if (!catItem || catItem.name !== 'Server Test')
return;
// Get the attachment linked to the catalog variable (ZZ_YYsc_req_item)
var attachGR = new GlideRecord('sys_attachment');
attachGR.addQuery('table_sys_id', ritm.sys_id);
attachGR.addQuery('table_name', 'ZZ_YYsc_req_item');
attachGR.query();
if (attachGR.next()) {
var emailAttach = new GlideRecord('sys_email_attachment');
emailAttach.initialize();
emailAttach.attachment = attachGR.sys_id;
emailAttach.file_name = attachGR.file_name;
emailAttach.source = 'notification';
emailAttach.content_disposition = 'attachment';
emailAttach.email = current.sys_id;
emailAttach.insert();
}
})(current, previous);
Thank You
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2025 09:43 PM
Hi @SM123,
Have you checked the Include attachments on your notification record yet?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2025 10:01 PM
@SM123 Is there any specific reason for using BR? I would recommend you to use Flow Designer to achieve this. This is easy and convenient way. Please let me know if you need any help with this.
Regards,
Ram Ardhani.