Copy Attachments from attachment variable in RITM to Catalog item form

praneeth7
Tera Guru

Hi,

Here I'm stuck with an issue, that I want copy Attachment from Attachment variable in RITM table to Catalog item form using UI Action. I have tried with this script and I'm not getting any output. 

GlideSysAttachment.copy('ZZ_YYsc_req_item',sourceSYSID','sc_cat_item',sys_id=targetSYSID');
var count = 0;
var gsa = new GlideSysAttachment();

var att = new GlideRecord('sys_attachment');
att.addQuery('table_name', 'ZZ_YYsc_req_item');
att.addQuery("table_sys_id", current.sys_id);
att.query();

 

When I click the refill button it should redirect to the catalog item and the Attachment which stored in attachment variable should paste in the catalog item form

 

@Ankur Bawiskar @Joshwa Antony Sebastian @michelhanna 

6 REPLIES 6

Hi,

your question was for copying the file and not for redirection.

Can you explain UI action is on which table?

If it's on RITM table then update as this

var gr = new GlideRecord("sys_attachment");
gr.addQuery("table_name", "ZZ_YY" + current.getTableName());
gr.addQuery("table_sys_id", current.sys_id);
gr.query();
if (gr.next()) {
	gr.table_name = current.getTableName();
	gr.update();
	new global.VariableUtil().copy(gr.sys_id, current.getTableName(), current.sys_id); 
}

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@praneeth 

Hope you are doing good.

Did my reply answer your question?

If my response helped please close the thread by marking appropriate response as correct so that it benefits future readers.

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader