UI action to copy attachment from incident table to existing work order records
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2023 12:54 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2023 04:14 AM
plz share the common field between incident table and wm_order table which will be using as reference for copying attachment to that record.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2023 04:25 AM
We have field on wm_order tabe named "initiated_from" which store the incident num.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2023 04:41 AM
var gr= new GlideRecord('wm_order');
var wn_num = current.number;
gr.addQuery('initiated_from', wn_num);
gr.query();
var sysID="";
if(gr.next()){
sysID = gr.sys_id;
}
GlideSysAttachment.copy('incident', current.sys_id, 'wm_order',sysID);
gs.addInfoMessage("Attachment updated");
var mySysID = current.update();
Plz use this Script
Plz Mark my Solution as Accept and Give me thumbs up, if you find it Helpful.
Regards,
Samaksh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2023 04:53 AM
I have added addinfomessage and it gave me below result:-
var gr= new GlideRecord('wm_order');
var wn_num = current.number;
gs.addInfoMessage("Wokr order"+""+ wn_num);
gr.addQuery('initiated_from', wn_num);
gr.query();
var sysID="";
if(gr.next()){
sysID = gr.sys_id;
gs.addInfoMessage("SysID"+""+ sysID);
}
GlideSysAttachment.copy('incident', current.sys_id, 'wm_order',sysID);
gs.addInfoMessage("Attachment updated");
var mySysID = current.update();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2023 04:59 AM
Hello @Kunal33
Are you writing this Script on Incident table ??
Plz Mark my Solution as Accept and Give me thumbs up, if you find it Helpful.
Regards,
Samaksh