AutoClose Related incidents when incident state is onhold, when problem state is resolved
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2024 11:05 AM - edited 05-08-2024 09:27 PM
Hi Team,
I need to Resolve Related incidents when incident state is onhold, when problem state is resolved.
I have written after insert or update business rules. Condition is state is resolved.
Script:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-15-2024 04:34 AM - edited 05-15-2024 04:35 AM
Hi @Sriram17
Can you explain in detail of what is not working?
Change the condition to " State changes to Resolved".( So that It won't trigger if any more updates are done in resolved state)
Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-15-2024 05:40 AM - edited 05-15-2024 05:41 AM
Hi @Sriram17 ,
You need to add one more line of code as below,
(function executeRule(current, previous /*null when async*/ ) {
var incidentGr = new GlideRecord('incident');
incidentGr.addQuery('problem_id', current.sys_id);
incidentGr.addQuery('state', 3);
incidentGr.query();
while (incidentGr.next()) {
gs.info('inside while line no 10');
incidentGr.state = 6;
incidentGr.close_code ='Resolved by problem';
incidentGr.close_notes = "Automatically Resolved due to resolution of associated problem: " + current.number;
incidentGr.update();
}
})(current, previous);
Please mark this comment as Correct Answer/Helpful if it helped you.
Regards,
Swathi Sarang