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

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

I shared solution for this 2years ago

Disable ZZ_YY prefix from attachment when added through record producer

Regards
Ankur

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

hi, 

Thanks for your reply,

I have tried with UI action but it's not working properly. I have attached the image extra clarification. how can I exactly copy attachment from attachment variable to service catalog by clicking refill button ?

can you help me with code!

thank you

Hi,

I already shared link where I provided solution for what you asked i.e. how to copy file attached to attachment variable to target record

What's not working?

Can you share what script did you tried?

Regards
Ankur

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

Hi

I have tried with this script. When I'm using this script it's not redirecting to the catalog item. if I click UI action it takes me to the previous page. 

var attachment = new global.GlideQuery('sys_attachment')
	.where('table_sys_id', current.sys_id)
	.where('file_name', current.<field_name>.getDisplayValue())
	.selectOne('table_sys_id')
	.get();

	new global.VariableUtil().copyAttachment(attachment.sys_id, 'sys_data_source', dataSourceID);