UI action to copy attachment from incident table to existing work order records

Kunal33
Tera Expert

Hi Team,

We have a requirement to create a UI action--Copy attachment to work order on attachment related list on incident form . With this UI action, when we select attachment and click on this button, it copy the selected attachment and move the attachment to related work orders. 

34 REPLIES 34

Samaksh Wani
Giga Sage
Giga Sage

Hello @Kunal33 

 

Use this Script :-

 

var gr = new GlideRecord('destination_table');

var sysID = gr.insert();


GlideSysAttachment.copy('incident_table, current.sys_id, 'destination_table', sysID);


var mySysID = current.update();
current.deleteRecord();

 

 

Plz Mark my Solution as Accept and Give me thumbs up, if you find it Helpful.

 

Regards,

Samaksh

HI ,

 

We have created a UI action on Global table. please check the below code:_

 

Condition:- RP.isRelatedList() && current.getTableName()== 'sys_attachment' && parent.sys_class_name == 'incident';

 

Script 

 

var gr= new GlideRecord('wm_order');
var sysID = gr.Insert();

GlideSysAttachment.copy('incident', current.sys_id, 'wm_order',sysID);

gs.addInfoMessage("Attachment updated");
var mySysID = current.update();

 

 

 

Yes 

i tried with above but nit working