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

Inactive_Us1474
Giga Guru

you need to create a background script for inserting a new record.


sujithanagaraju
Kilo Contributor

Hi Akhil,



Can you please help me with the script?



Thanks,


Sujitha


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


windows
Mega Contributor

Hi,



But in this code what changes should I make so that I get the attachments loaded succesfully