Get a first look at what's coming. The Developer Passport Australia Release Preview kicks off March 12. Dive in! 

How to get all child incidents number associated with particular Parent incident using Script ?

Tejas16
Tera Contributor

How to get all child incidents number associated with particular Parent incident using server side Script? 

1 ACCEPTED SOLUTION

Raghav Sharma24
Giga Patron

Run below script in background script, it will print all child incidents.

var inc = new GlideRecord('incident');
inc.addQuery('parent', ' ');  // pass the sys_id of parent incident
inc.query();
while(inc.next())
{
gs.print(inc.number);  // it will print all child incident numbers
}


Please mark the answer correct/helpful accordingly.

View solution in original post

3 REPLIES 3

Raghav Sharma24
Giga Patron

Run below script in background script, it will print all child incidents.

var inc = new GlideRecord('incident');
inc.addQuery('parent', ' ');  // pass the sys_id of parent incident
inc.query();
while(inc.next())
{
gs.print(inc.number);  // it will print all child incident numbers
}


Please mark the answer correct/helpful accordingly.

Only Small change is there:

Replace parent with parent_incident.

How write a background script in servicenow to get the parent and child incident records for the entire incident table in database and not just for one parent incident record