Duplicate a service request ticket

sujithanagaraju
Kilo Contributor

Is there any way to easily duplicate an service request REQ ticket, including the attachments?

We are using helsinki.

Can any one help us on this?

Thanks,

Sujitha

1 ACCEPTED SOLUTION

Hi Sujitha,


Try using Ui action:



Name:Duplicate Request


Action name:duplicate_request                   //this name is using in script so if u change this name then u need to change in script also


Show Update: True


Client:True


Form Button:True


Onclick: runClientCode()


Script:



function runClientCode(){


var answer1 = confirm("Are you sure you want to create duplicate request? ");


  if (answer1 == false) {


  return false;


}


  gsftSubmit(null, g_form.getFormElement(), 'duplicate_request');


}



if(typeof window == 'undefined')


    runBusRuleCode();




function runBusRuleCode(){



  var sys_id=current.sys_id;


var req = new GlideRecord("sc_request");


  req.initialize();


req.short_description = current.short_description;


req.description='Dupplicate Requset' ;


req.requested_for=current.requested_for;



//add more action



req.insert();



  var gl=new GlideRecord("sys_attachment");


  gl.addQuery('table_sys_id',sys_id);


  gl.query();


  while(gl.next()){


  var table=gl.table_name;


  var File=gl.file_name;


  var content=gl.content_type;



  var attach=new GlideRecord('sys_attachment');


  attach.intialize();


  attach.table_name=table;


  attach.file_name=File;


  attach.content_type=content;


  attach.table_sys_id=req.sys_id;


  attach.insert();


  }



//current.deleteRecord();


gs.addInfoMessage("Request " + req.number + " created");


action.setRedirectURL(req);


action.setReturnURL(current);


}



find_real_file.png


find_real_file.png


Let me know if it resolves your issue.


PS:Mark helpful or correct if this solves your issue.


Thanks,


farukh


View solution in original post

8 REPLIES 8

//Here you go. This case would apply if you need it for one request. //As per your use case, add the fields which needs to be copied. //If required to copy attachment from item/sc_task table add more attachment statements. var req=new GlideRecord('sc_request'); req.addQuery('number','REQ0010013'); req.query(); if(req.next()) { var req1= new GlideRecord('sc_request'); req1.initialize(); req1.number= "REQ0010055"; req1.insert(); var req2= new GlideRecord('sc_req_item'); req2.intialize(); req2.number= "RITM0010055"; req2.request=req1.sys_id; req2.insert(); var req3= new GlideRecord('sc_task'); req3.initialize(); req3.number= "TASK0010055"; req3.request_item=req2.sys_id; req3.insert(); GlideSysAttachment.copy('sc_request', req.sys_id , 'sc_request', req1.sys_id); } Hope it helps.


drjohnchun
Tera Guru

This should give you a good starting point - the script also copies attachments:



'Copy' UI action for Change requests (Part 2!)



Please feel free to connect, follow, mark helpful, like, endorse.


John Chun, PhD PMP see John's LinkedIn profile


visit snowaid


sujithanagaraju
Kilo Contributor

Thanks for evryone


sujithanagaraju
Kilo Contributor

Hi Everyone,



Can any one guide us how to display the duplicate ticket number in the original ticket so that user can understand which is the duplicate one & viceversa?



Thanks,


Sujitha