MRVS Attachment to Copy on Actual Ticket

Dark Kei
Tera Expert

Hi! How to copy the attachment from MRVS to the actual request ticket?

8 REPLIES 8

Dark Kei
Tera Expert

I actually was able to copy using:

DarkKei_1-1751610790612.png

But it copies all the attachments from the same source. Is there a way to copy a single attachment?

 

@Dark Kei 

did you get a chance to check my above response where I shared solution?

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

Hi @Dark Kei ,

Please use the below code to copy single attachment from MRVS table to target table.

 

 

var gr = new GlideRecord('your_mrvs_table'); // your MRVS table
if (gr.get('sys_id', 'MRVS_RECORD_SYS_ID')) {
var attachments = new GlideRecord('sys_attachment');
attachments.addQuery('table_sys_id', gr.sys_id);
attachments.addQuery('table_name', 'your_mrvs_table');
attachments.orderBy('sys_created_on');
attachments.setLimit(1);
attachments.query();

if (attachments.next()) {
GlideSysAttachment.copy('your_mrvs_table', gr.sys_id, 'sc_request', 'REQ_SYS_ID');
}
}

 

Please accept my solution and give helpful if the above codes work for you.