- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-24-2024 08:33 AM
Hello Team,
Literally, you are my last resort. I have reached a point where given my skill set, I don't know what else I can do.
- I have an email notification active on the sysapproval_approver table.
- The category of the notification is "Approval".
- This notification is "Send When" an "Event is Fired" the event is called "approval_inserted".
- The notification is using a specific email template called "change.itil.approve.role.extra.funds".
- The notification is triggered for cat item.
I can't figure out how to include the attachments in the RITM into the email notification.
Action taken and rationale
- As mentioned above, the email notification is active in the sysapproval_approver table, so (correct me if I am wrong) I must make sure the attachments are copied from the RITM to the approval record created.
- Based on this assumption I created a flow which is triggered when a new approval record is created and copies the attachments (if any) from the RITM to the approval record. The flow works and does what I want
- In order to attach the files in the email notification, I need to copy the files from the approval record to the email record in the sys_email table
- Based on this assumption I created business rules on the sys_email table (see below the "When to run" conditions and the code I used.
(function executeRule (current, previous /*null when async*/) {
var sourceID = current.instance.sys_id;
var sourceTable = current.instance.sys_class_name;
var targetID = current.sys_id;
//GlideSysAttachment.copy(sourceTable, sourceID, targetTable, targetID);
GlideSysAttachment.copy(sourceTable, sourceID, 'sys_email', targetID);
})(current, previous);
The attachments...just don't get copied over :(.
I know this topic has been discussed multiple times, but I could not find a solution which works for me in the other posts.
Thank you.
Regards.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-25-2024 12:52 AM
@AEterni - Please refer the below community link to copy the attachments to approval record.
https://www.servicenow.com/community/developer-articles/adding-attachments-to-email/ta-p/2320991
Just for discussion:
Let us consider the Real time use cases:
Not recommended:
1. Let us say, if we are copying the attachments from RITM to Approval records, it will consume more memory
2. For one RITM, if there are more than one approvals, the point number 1 will be multiplied.
3. the load on the instance will be more
Best practices:
1. Generate link to attachments in the email notification to have the direct access to the attachment.
(Please refer this link: https://www.servicenow.com/community/now-platform-forum/attachments-in-notifications/m-p/1243477)
2. Make the approver have read access to the related approval record (RITM in this case) so that the approver can see what is requested, why he needs to approve. Then no need to copy the attachments.
3. If the approver is business user, then "business_stakeholder" role can help to see the RITM.
Please let me know, if you have further questions.
Thank you.
Regards,
Karunakaran.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-25-2024 12:27 AM
I did not mention that this is not working because of the license. It is good to know, if there is a license involved.