Closed child incident when the parent incident close
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-09-2024 08:04 AM
When the incident moved to closed all the child incidents also moved to close.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-12-2024 08:28 AM
Hello @Payal Tripathy ,
Create after update Business rule on incident table and select condition like state is closed and write below code in script section.
var grInc= new GlideRecord('incident');
grInc.addQuery('parent',current.sys_id);
grInc.query();
while(grInc.next())
{
grInc.state=7;
grInc.update()
}
Please refer the below link.
Please mark my answer as helpful and correct if it resolves your issue.
Regards,
Namrata
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-12-2024 11:00 AM
Hi @Payal Tripathy .
Please create a Before Business Rule on incident table and add Below script
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
if (current.state == 7) {
gs.log("Inside Close inc = " + current.state, 'closeINc');
current.close_code = 'User Error';
current.close_notes = 'TESTETST';
var gr = new GlideRecord('incident');
gr.addQuery('parent_incident', current.sys_id);
gr.query();
while (gr.next()) {
gs.log("Child Parent = " + gr.parent_incident + " CUrrent = " + current.sys_id, 'closeINc');
gs.log("Inside while = " + gr.number, 'closeINc');
gr.setValue('state', 7);
gr.setValue('close_code', 'User Error');
gr.setValue('close_notes', "TESTETETS");
gr.update();
}
}
})(current, previous);
Please mark my answer correct and helpful if this works for you
Thanks and Regards
Sarthak
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-12-2024 11:52 AM
You can create after update business rule and add condition as when state changes to closed on incident table.
Add below script:
This will definitely helps you to resolved your issue. Let me know in case you need to understand the flow or you can DM on LinkedIn.
If this solution resolves your query, kindly mark it as the accepted solution and give it a thumbs up.
Best Regards,
Krushna Birla
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-12-2024 12:39 PM - edited ‎05-12-2024 01:03 PM
Hi @Payal Tripathy ,
You can do it through script or achieve it through OOTB solution,
OOTB solution,
when Parent incident is resolved, it resolves the child incident aswell and it will be closed based on the days set in the incident property.
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0994346
Through script:
Write after update business rule on Incident table,
Condition: State is closed
(function executeRule(current, previous /*null when async*/) {
var childInc = new GlideRecord('incident');
childInc.addQuery('parent_incident',current.sys_id);
childInc.query();
while(childInc.next()){
//gs.info('inside while');
childInc.state = "7" ;
childInc.incident_state = "7" ;
childInc.close_code = current.close_code;
childInc.close_notes =current.close_notes;
childInc.update();
}
})(current, previous);
Please mark this comment as Correct Answer/Helpful if it helped you.
Regards,
Swathi Sarang