Copy Attachment from one table to another | Attachment from sysapproval_approver to Parent ticket
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Hi,
I need help to create Business Rule to copy attachment from the approver record on (sysapproval_approver) to the parent record which is on custom table (x_tech_request)
I don't want to use flow
Thanks,
S
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Hi @DanaWood ,
Please review the below link , there is already solution provided -
if it's helpful please mark as helpful and accept the solution in order to close the thread.
Thank you!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
you can use after insert BR on sys_attachment table
Condition: current.table_name == 'sysapproval_approver'
Script:
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
var gr = new GlideRecord("sysapproval_approver");
gr.addQuery("sys_id", current.table_sys_id);
gr.query();
if (gr.next()) {
var rec = new GlideRecord('x_tech_request');
if (rec.get(gr.document_id)) {
new GlideSysAttachment().copy('sysapproval_approver', gr.getUniqueValue(), 'x_tech_request', rec.getUniqueValue());
}
}
})(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
yesterday
@Ankur Bawiskar thanks for your reply, it works but every time I add attachment to add all attachment again to the request.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
@Ankur Bawiskar Thanks for your reply! it works but it keeps adding the old attachment with every new one.