How to create a case from incident

sriram35
Kilo Guru

How to create a case from incident

3 REPLIES 3

AbhishekGardade
Giga Sage

Hello Sri,

What is a case here? Is it a custom table?

You can create a record using below code:

var gr = new GlideRecord('table_name');
gr.initialize();
gr.name = 'first to do item';  
gr.description = 'learn about GlideRecord';

// you can set any field values using gr.fieldName = 'values you want to set'
gr.insert();

Reference:

https://developer.servicenow.com/app.do#!/api_doc?v=kingston&id=r_GlideRecord-initialize

Please mark as Correct Answer/Helpful, if applicable.
Thanks!
Abhishek Gardade

Thank you,
Abhishek Gardade

Jaspal Singh
Mega Patron
Mega Patron

Hi Sriram,

 

You can create a UI Action: Create Case that appears on Incident state & configure script as below.

var gr = new GlideRecord('sn_customerservice_case');
gr.short_description = current.short_description;
gr.description = current.description;
var customerservicecase= gr.insert();

GlideSysAttachment.copy('incident', current.sys_id, 'sn_customerservice_case', customerservicecase); //copies attachment if any can be commented if required.

current.u_incident= customerservicecase;////Considering there is a custom Incident field on customer service form that copies the sys_id of incident.
current.update();

action.setRedirectURL(gr);

 

Thanks,

Jaspal Singh

 

Hit Helpful or Correct on the impact of response.

 

Monali Patil
Kilo Guru

Hello Sriram,

Please go through below link,

https://developer.servicenow.com/app.do#!/api_doc?v=kingston&id=r_GlideRecord-initialize

Hope your problem will be solve.

 

 

Thanks,

Monali Patil

 

mark as Helpful or Correct on the impact of response.