- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2022 12:56 AM
Hi,
I have a requirement of copying attachments from sctask to ritm table and below is the business rule I have tried but this added attachment thrice and even I need to avoid duplicate attachments.
Please someone could help!
Table - sys_attachment
when to run - before, on insert and update.
var taskAtt = new GlideRecord('sc_task');
taskAtt.addQuery('sys_id', current.table_sys_id);
taskAtt.query();
if(taskAtt.next()){
var reqAtt = new GlideRecord('sc_req_item');
reqAtt.addQuery('sys_id',taskAtt.request_item);
reqAtt.query();
if(reqAtt.next()){
GlideSysAttachment.copy('sc_task', current.table_sys_id, 'sc_req_item', reqAtt.sys_id);
}
}
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2022 05:59 AM
Hi Gunjan,
This will delete existing attachment which is already present in RITM, which should not be where it should only copy the attachments from SCTASK.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2022 06:04 AM
Hi @Dhanalakshmi D ,
Then you can try below solution:-
Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2022 01:03 AM
Hi @Dhanalakshmi D ,
You can delete existing attachment and copy the all attachment again as suggested in below post by Ankur.
Prevent duplicate attachments when copying
Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2022 01:06 AM
Hi @Dhanalakshmi D ,
You can also copy latest attachment only by referring to the below thread code :- It will also eliminate duplicate's
Copy Newest Attachment Only From Task to RITM
Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2022 05:40 AM
Hi Gunjan,
This will delete existing attachment which is only in RITM which should not be.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2022 05:59 AM
Hi Gunjan,
This will delete existing attachment which is already present in RITM, which should not be where it should only copy the attachments from SCTASK.
Thanks