Approval email is missing RITM attachments

chrish5
Giga Guru

I'm using the below script to create a request from an inbound email that will have attachments  The workflow that runs for this request sends out an approval notification and this notification is checked to "Include Attachments", but the attachments are not on the approval email.  I've verified that the email log Action says "Attached to the Target Record" and the RITM of the REQ has the attachments, but the approval email does not have the attachment for the approver to review.  Can someone tell me what is missing?  

 

// Create the 'parent' REQ record
var grREQ = new GlideRecord('sc_request');
grREQ.short_description = "MDF door access audit";
var reqSysID = grREQ.insert();
// 'current' = RITM record, update variables and insert.   This will include file attachments from original email
current.short_description = "MDF door access audit";
current.cat_item='d9a69b671b1b611092beea40604bcbda';
current.request=reqSysID;
current.requested_for='72d53761db102200bcbed540cf961919';
var gdt = new GlideDateTime();
current.state=0;
current.insert();
// Update state, this kicks off the work flow.   Without this, no WF will be attached until RITM is manually updated
current.state=1;
current.update();
// Stop further processing of inbound emails
event.state="stop_processing";
1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@chrish5 

Include attachment works when the record on which notification triggers has file attached to it.

I consider your email is on sysapproval_approver table

So unless you attach file to approval record it won't send the file as attachment in email

So you copy the file from RITM to approval record using GlideSysAttachment.copy() method and then it will work

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

5 REPLIES 5

Tony Chatfield1
Kilo Patron

Hi, based on details in your post I would suspect your issue that is the approval notification is triggered from a record on the sysapproval_approver table, but your attachments are on the approvals related task IE sc_request and so the notification 'attachment' flag has no impact as the triggering record has no attachments.
You could try copying the attachments from your request to the approval record, but this does result in an increased overhead as the attachments are effectively duplicated across X number of approval records.
A variation of this notification email script from SNCGuru may also provide a solution, by adding links to attachments in the email message.

Send an Email Notification with Associated Attachments - ServiceNow Guru

Hi Tony,

Thanks for your response.  I would prefer to have the attachment on the approval notification.  Do you have an example of how this may be accomplished.   Thanks!

I ended up putting an async before business rule in place with the below script to copy the attachments from the RITM to the approval notifications.  

 

GlideSysAttachment.copy('sc_req_item', current.sysapproval.sys_id, 'sysapproval_approver', current.sys_id);

Ankur Bawiskar
Tera Patron
Tera Patron

@chrish5 

Include attachment works when the record on which notification triggers has file attached to it.

I consider your email is on sysapproval_approver table

So unless you attach file to approval record it won't send the file as attachment in email

So you copy the file from RITM to approval record using GlideSysAttachment.copy() method and then it will work

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader