Attachment to from RITM to SCTASK

RobertPC
Tera Contributor

I have created a Business Rule to copy attachments from the RITM to the SCTASK with the following script:

 

var gr = new GlideRecord("sc_task");
gr.addQuery("request_item", current.sys_id);
gr.query();
while(gr.next()) {
GlideSysAttachment.copy('sc_req_item', current.request_item, 'sc_task', gr.sys_id);
}

 

And it does not seem to be working. Any help would be greatly appreciated.

 

2 REPLIES 2

GTSNOW
Giga Guru

Hi,

 

Try this. 

(function executeRule(current, previous /*null when async*/) {

	// Add your code here
	if (current.hasAttachments())
	{
	var gr = new GlideRecord('sc_task');
	gr.addQuery('request_item',current.sys_id);
	gr.query();
	while (gr.next())
	{
		var a = new GlideSysAttachment();
		a.copy('sc_req_item',current.sys_id,'sc_task',gr.sys_id);
	}
	}
})(current, previous);

 

GTSNOW_0-1693944380774.pngGTSNOW_1-1693944390337.png

If you found my response helpful or relevant to your query, please consider clicking the "Helpful" button or giving it a "Like". This not only helps others identify useful replies but also encourages contributors like me to continue assisting the community. Thank you for your support!

PatLeb
Tera Contributor

is the BR on insert? update?

after or Before?