- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2025 09:19 PM
I need a specific pdf document to be attached physically to the email notification when it's sent out. It shouldn't be a link to the pdf but it should be a physical file where the users can access the pdf without Servicenow access. How can it be achieved? Also, I need to know how to test the whether the attachment is included or not in email logs? Thanks in advance.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2025 10:30 PM
yes it's possible. but the file has to be stored in some record.
I shared solution for something similar 2 years ago
Adding latest attachment from sys_attachment table to sys_email record
1) create a system property and add your file to it
2) then create after insert BR on sys_email with condition as this
You change the table as sc_req_item
BR script
(function executeRule(current, previous /*null when async*/) {
var propertyRecordSysId = ''; // give here the sysId of newly created system property record where file is present
var s_Attach = new GlideRecord('sys_attachment');
s_Attach.addEncodedQuery('table_sys_id=' + propertyRecordSysId);
s_Attach.query();
if(s_Attach.next()){
var rec = new GlideRecord('sys_email_attachment');
rec.initialize();
rec.attachment = s_Attach.sys_id;
rec.file_name = s_Attach.file_name;
rec.source = 'notification';
rec.content_disposition = 'attachment';
rec.email = current.sys_id;
rec.insert();
}
})(current, previous);
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-07-2025 11:40 PM
yes if it comes in email attachment tab then it will be sent, it's OOB
Thank you for marking my response as helpful.
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-07-2025 09:44 PM
the file has to be on the record from where notification is getting triggered.
You can use Include attachment checkbox on notification and the physical file will be sent
Can you share details notification is on which table?
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-07-2025 09:56 PM
The notification trigger record will be the RITM when it's closed complete. The notification is on sc_request_item table.
Is there any way of adding it in the email instead of adding the file on every ritm rceord?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2025 10:30 PM
yes it's possible. but the file has to be stored in some record.
I shared solution for something similar 2 years ago
Adding latest attachment from sys_attachment table to sys_email record
1) create a system property and add your file to it
2) then create after insert BR on sys_email with condition as this
You change the table as sc_req_item
BR script
(function executeRule(current, previous /*null when async*/) {
var propertyRecordSysId = ''; // give here the sysId of newly created system property record where file is present
var s_Attach = new GlideRecord('sys_attachment');
s_Attach.addEncodedQuery('table_sys_id=' + propertyRecordSysId);
s_Attach.query();
if(s_Attach.next()){
var rec = new GlideRecord('sys_email_attachment');
rec.initialize();
rec.attachment = s_Attach.sys_id;
rec.file_name = s_Attach.file_name;
rec.source = 'notification';
rec.content_disposition = 'attachment';
rec.email = current.sys_id;
rec.insert();
}
})(current, previous);
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-07-2025 11:40 PM
This is working. Also, I need to know how to test the whether the attachment is included or not in email logs. If it's included in the email attachments tab in the email log, will it be sent as an attachment?