all old attachments are coping on every new attachment update in SC_TASK to RITM.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
Hi All,
I am using the below script to copy the attachments from sc task to RITM, if any fulfiller attachdocument to sctask that need to be shown to customer (to copy to RTIM). but on every attachment upload all other attachments in SC TAsk is copying to RITM including new one.
-------------------------------------------------------------------------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
that's OOTB behavior when you use copy() method
Approach 1:
-> delete files on target before copying and then use copy() method
I shared approach few years ago
Prevent duplicate attachments when copying
OR
Approach 2:
-> copy only specific file
I shared approach for this as well 6-7 years ago
Is there any way to copy single attachment from multiple attachments ??
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
34m ago
It is best practice to avoid copying attachments whenever possible, due to adding unnecessary database bloat, and the confusion this will cause when the attachments become out of sync between the two records because one is deleted in one place, but not the other...
Consider an alternate approach. You can create a Related List to add to the RITM form that shows all of the attachments on all of the Catalog Tasks related to this RITM. To do this, first create a new Relationship that looks like this:
You can name it whatever you want to appear on the tab on the RITM record. Here is the script:
function refineQuery(current, parent) {
var childArr = [];
var sctask = new GlideRecord('sc_task');
sctask.addQuery('request_item', parent.sys_id);
sctask.query();
while (sctask.next()) {
childArr.push(sctask.sys_id.toString());
}
current.addQuery('table_sys_id', 'IN', childArr);
})(current, parent);
On an RITM record, right-click and Configure > Related Lists to add your new Relationship name.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
28m ago
copying files on records will increase attachment table size
instead you can show them via related list
see this blog and enhance
TNT: "Related Attachments" Related List
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
