Attachment over email
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2025 08:14 PM
I have dynamic attachments associated with case table.
But I have notification on sysapproval table need to send email while notification generated with all attachment linked to case table.
how to achieve it.
I have used BR on "sys_email" table. But it not copying attachment.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2025 08:27 PM
to send email notifications with attachments from the Case table when triggering notifications on the sysapproval table
Use GliseSysAttachmentProperly Ensure GliseSysAttachment.copy() uses correct table and sys_id references.
use following solution
var attachment = new GlideSysAttachment();
attachment.copy('case_table', case_sys_id, 'sys_email', current.sys_id);
Place the Business Rule after insert/update on sys_email. Ensure correct sys_id from the Case is referenced and consider filtering relevant attachments if needed before copying
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2025 08:31 PM
Hi @Hafsa1
we can try following code with After BR:
(function executeRule(current, previous /*null when async*/) {
// Get the case record associated with the current email (sys_email)
var caseRecord = current.instance; // This assumes `instance` field is the case reference on sys_email
// Ensure the case record exists
if (!caseRecord) {
return;
}
// Get the attachments from the case record
var attachmentGR = new GlideRecord('sys_attachment');
attachmentGR.addQuery('table_name', caseRecord.getTableName());
attachmentGR.addQuery('table_sys_id', caseRecord.sys_id);
attachmentGR.query();
// Copy each attachment to sys_email table
while (attachmentGR.next()) {
// Use GlideSysAttachment.copy to copy each attachment to sys_email
GlideSysAttachment.copy(attachmentGR, 'sys_email', current.sys_id);
}
})(current, previous);
suggestion: verify the sn_customerservice_north_america_procurement table contains attachments linked via the sys_attachment table. The sys_attachment table holds the actual files, and they need to be linked to both the sn_customerservice_north_america_procurement and sys_email records.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2025 08:56 PM
you can copy file from case record to approval record
OR
you can add file on sys_email directly
what BR did you write? share script and trigger condition screenshots etc
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-22-2025 04:17 AM
Hope you are doing good.
Did my reply answer your question?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader