Close Child Incidents without closing Parent incident

Praveen55
Kilo Explorer

Hello All,

Am new to Servicenow and trying to explore stuff for daily activities. We come across cases where multiple alerts (incidents) trigger for an issue and have to end up creating a parent and linking others to it. 

While we investigate on the parent incident, have to close the child incidents. I would need your support on this activity

Child incidents can be in any State (new, in progress) but have to close all without closing Parent

Kindly assist

14 REPLIES 14

Sorry. I missed your question.

Try this condition

var inc = new GlideRecord('incident');inc.addQuery('active','true');iinc.addQuery('parent_incident',current.sys_id);inc.query();if (inc.next()) true; else false;

 

Please mark my response correct if it worked for you

 


Please mark this response as correct or helpful if it assisted you with your question.

Before trying the provided condition, I have mentioned the below for making the UI action visible to certain groups only

 

gs.getUser().isMemberOf('Group 1') || gs.getUser().isMemberOf('Group 2 ') || gs.getUser().isMemberOf('Group 3') ||  gs.getUser().isMemberOf('Group 4')

 

How do I add more groups for them to view the UI action and also how can I add the condition provided by you together ?

I would suggest writing a classless script include and then call it in the condition as showCancel()

 

function showCancel()

{

if (gs.getUser().isMemberOf('Group 1') || gs.getUser().isMemberOf('Group 2 ') || gs.getUser().isMemberOf('Group 3') ||  gs.getUser().isMemberOf('Group 4'))

{

var inc = new GlideRecord('incident');

inc.addQuery('active','true');

iinc.addQuery('parent_incident',current.sys_id);

inc.query();

if (inc.next())

return true;

}

return false;

}


Please mark this response as correct or helpful if it assisted you with your question.

Unfortunately, its not working with the below script

- Its visible to all members whoever is not member of the Group 1

 

function showCancel()
{
if (gs.getUser().isMemberOf('Group 1'))
{
var inc = new GlideRecord('incident');
inc.addQuery('active','true');
inc.addQuery('parent_incident',current.sys_id);
inc.query();
if (inc.next())
inc.state=6;
inc.close_notes='Closing from parent incident';
inc.update();
}
}

You were supposed to be creating a script include. And then call the function in condition as showCancel()

 

function showCancel()

{

if (gs.getUser().isMemberOf('Group 1') || gs.getUser().isMemberOf('Group 2 ') || gs.getUser().isMemberOf('Group 3') ||  gs.getUser().isMemberOf('Group 4'))

{

var inc = new GlideRecord('incident');

inc.addQuery('active','true');

iinc.addQuery('parent_incident',current.sys_id);

inc.query();

if (inc.next())

return true;

}

return false;

}


Please mark this response as correct or helpful if it assisted you with your question.