- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-11-2025 12:57 AM
I have a catalog item, when submitted it checks if the type is resource onboarding, if yes then it has to send an pdf document as an attachment to the user in an email . I want to achieve this in flow designer.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-11-2025 09:46 AM
so it's a standalone PDF.
You can create a system property and add PDF to that property 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
‎06-16-2025 03:25 AM
I believe I answered your original question and you can enhance it further based on your requirement and development skills.
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
‎06-16-2025 03:29 AM
The below code has worked properly.
(function executeRule(current, previous /*null when async*/) {
var subject = current.subject.toLowerCase();
var propertyRecordSysId = '';
gs.info("Email Subject: " + subject);
if (subject.includes("pdf for resource onboarding")) {
propertyRecordSysId = 'f4cd80da470ae65088e18c38c26d43a7';
} else if (subject.includes("pdf for resource offboarding")) {
propertyRecordSysId = '57a461e247862e5088e18c38c26d4358';
}
gs.info("Selected propertyRecordSysId: " + propertyRecordSysId);
if (propertyRecordSysId) {
var attachmentGR = new GlideRecord('sys_attachment');
attachmentGR.addQuery('table_name', 'sys_properties'); // Replace with actual table name
attachmentGR.addQuery('table_sys_id', propertyRecordSysId);
attachmentGR.query();
if (attachmentGR.next()) {
gs.info("Found attachment: " + attachmentGR.file_name);
var existingAttachment = new GlideRecord('sys_email_attachment');
existingAttachment.addQuery('email', current.sys_id);
existingAttachment.addQuery('attachment', attachmentGR.sys_id);
existingAttachment.query();
if (!existingAttachment.hasNext()) {
var emailAttachment = new GlideRecord('sys_email_attachment');
emailAttachment.initialize();
emailAttachment.attachment = attachmentGR.sys_id;
emailAttachment.file_name = attachmentGR.file_name;
emailAttachment.source = 'notification';
emailAttachment.content_disposition = 'attachment';
emailAttachment.email = current.sys_id;
emailAttachment.insert();
gs.info("Attachment inserted into email: " + current.sys_id);
} else {
gs.info("Attachment already exists for this email.");
}
} else {
gs.info("No attachment found for sys_id: " + propertyRecordSysId);
}
} else {
gs.info("No matching subject found.");
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-11-2025 09:12 AM - edited ‎06-11-2025 09:12 AM
@Harithapola Do you want to generate PDF containing data from RITM record ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-11-2025 09:14 AM
No, its just a different PDF.