Issue attaching file to Email Client Template from HR Agent Workspace
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
I need to pull in the attachments from 2 separate managed documents records when I apply an Email Client Template from the HR Agent workspace on an Employee Relations case. Template is applied, but the attachments are not being attached to the email draft.
I have the Email Client Template name set up as "Medical Documentation Cover Letter"
I have the Managed documents records set with names of " ER Accommodation Provider Request Medical Info" and "ER Accommodation 2026 ROI"
I have a business rule executing on the "sys_email_draft_ table; when to run = After Insert; and the following script:
(function executeRule(current, previous) {
// TEMPLATE CHECK
var templateName = (current.getDisplayValue('template') + '').toLowerCase().trim();
if (templateName != 'medical documentation cover letter') {
return;
}
// DOCUMENT NAMES
var documentNames = [
'ER Accommodation Provider Request Medical Info',
'ER Accommodation 2026 ROI'
];
for (var i = 0; i < documentNames.length; i++) {
var docRevGr = new GlideRecord('dms_document_revision');
docRevGr.addQuery('document.name', documentNames[i]);
docRevGr.addQuery('active', true);
docRevGr.orderByDesc('sys_created_on');
docRevGr.setLimit(1);
docRevGr.query();
if (!docRevGr.next()) {
gs.warn('No revision found for: ' + documentNames[i]);
continue;
}
// COPY ATTACHMENTS
GlideSysAttachment.copy(
'dms_document_revision',
docRevGr.getUniqueValue(),
current.getTableName(),
current.getUniqueValue()
);
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3m ago