Soumitra Das & Ria Dutta : How do I automatically copy attachments from a Catalog Task

soumitrardutta
Kilo Contributor

Hi everyone! My name is Soumitra Das and I’m an Oxford UK based entrepreneur, and together with my friend, Ria Dutta (tech Author) — we run a IT start-up.

 

By default, attachments added to a task are "trapped" there. This is a classic "How-To" that requires a specific Script Include or a Flow logic to ensure the requester can actually see what the agent uploaded.

 

Regards:
Soumitra Das & Ria Dutta

 

1 REPLY 1

Brad Bowman
Kilo Patron

The best approach is to not do this.  Copying attachments causes unnecessary database bloat and load to do the copying, and that's not even considering keeping them in sync between the two records.  If your requestors don't have view access to Catalog Tasks, and/or training/education to look there, you can create a custom Relationship that shows all attachments on all Catalog Tasks on the RITM record, for example. Your relationship would look something like this, with the Name being whatever you want to appear on the Related List tab

BradBowman_0-1769190699602.png

The Query with script to show all attachments on all Catalog Tasks related to this RITM would look like this:

(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);