Prevent duplicate attachments when copying
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2022 07:18 AM
I am using the below BR on the sys_attachment table to copy attachments added to sc_task to their parent RITM.
(function executeRule(current, previous /*null when async*/) {
var id = current.table_sys_id;
var gr = new GlideRecord('sc_task');
gr.addQuery('sys_id', id);
gr.query();
if(gr.next()){
var ritm = gr.request_item;
GlideSysAttachment.copy('sc_task', id, 'sc_req_item', ritm);
}
})(current, previous);
I run into issues with the following scenario:
Attachment1 added to sc_task and copied to ritm
Attachment 2 added to sc_task and the BR copies Attachment1 & Attachment2 to ritm
RITM ends up with Attachment1, Attachment1 & Attachment2.
How can I get this BR to not copy a attachment that's already been copied?
5 REPLIES 5
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2022 07:25 AM
Sharing few links as well if you wish to copy single file
Copy JUST a certain file type from one record to another
How to copy a single attachment?
Regards
Ankur
Regards,
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader