Hw to set an Incident as a Parent incident Using Script?

Varshini Vishpa
Kilo Contributor

I want to create a UI action button to create a new child incident with the current incident as a parent. 

1 ACCEPTED SOLUTION

Afrith Shariff
Tera Guru

Hi varshini,

 To make the current incident Parent incident firstly we create an incident form object. Initialize it and assign the sys_id to the current object. (make the UI action Server Side)

use insert() to insert it into the table or else you need to make some additional changes and click on submit button.

 

var gr = new glideForm('incident');
gr.initialize();
gr.parent_incident = current.sys_id;
// This will redirect to the child incident form
action.setRedirectURL(gr);

View solution in original post

5 REPLIES 5

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

should be simple enough

UI action will be server side

Something like this and you can enhance it further

// Create new incident record
var incident = new GlideRecord('incident');
incident.parent_incident = current.sys_id;
incident.cmdb_ci = current.cmdb_ci;
incident.category = current.category;
incident.subcategory = current.subcategory;
incident.caller_id = current.caller_id;
incident.insert();
gs.addInfoMessage("Child incident " + incident.number + " has been created");

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Varshini Vishpathas 

Hope you are doing good.

Did my reply answer your question?

If my response helped please close the thread by marking appropriate response as correct so that it benefits future readers.

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Harish KM
Kilo Patron
Kilo Patron

Hi there should be afield called as "parent_incident" you can use that for example in your UI Action

gr.parent_incident= current.sys_id ; // set it to parent field

Regards
Harish

Afrith Shariff
Tera Guru

Hi varshini,

 To make the current incident Parent incident firstly we create an incident form object. Initialize it and assign the sys_id to the current object. (make the UI action Server Side)

use insert() to insert it into the table or else you need to make some additional changes and click on submit button.

 

var gr = new glideForm('incident');
gr.initialize();
gr.parent_incident = current.sys_id;
// This will redirect to the child incident form
action.setRedirectURL(gr);