- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2022 10:30 AM
Hello Everyone,
I have a task where I need to show error message WHEN user tries to update an incident's state to resolved and there is an incident task whose state is open. Can someone guide me for this.
Regards,
Anand.
Solved! Go to Solution.
- Labels:
-
Incident Management

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2022 10:35 AM
Hi Anand,
You need to create a Before Update BR for this on incident table.
Action: State To Resolved or Closed
Script:
(function executeRule(current, previous /*null when async*/) {
var gr = new GlideRecord('incident_task);
gr.addQuery('active','true');
gr.addQuery('state',1); // you may want to use this if you need to check other states like Pending etc. (('state', 'NOT IN', '3,4,7');)
gr.addQuery('incident',current.sys_id);
gr.query();
if (gr.next()) {
gs.addErrorMessage('Please close the incident task(s) before resolving the incident');
current.setAbortAction(true);
}
})(current, previous);
Please mark correct/helpful if applicable.
Regards,
Shubham
Shubham Tipnis
ServiceNow Enthusiast
⭐️ 3x Rising Star (2022–2024) – ServiceNow Community
Sharing insights, use cases & real-world learnings from the Now Platform
Always learning. Always building.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2022 10:35 AM
Hi Anand,
You need to create a Before Update BR for this on incident table.
Action: State To Resolved or Closed
Script:
(function executeRule(current, previous /*null when async*/) {
var gr = new GlideRecord('incident_task);
gr.addQuery('active','true');
gr.addQuery('state',1); // you may want to use this if you need to check other states like Pending etc. (('state', 'NOT IN', '3,4,7');)
gr.addQuery('incident',current.sys_id);
gr.query();
if (gr.next()) {
gs.addErrorMessage('Please close the incident task(s) before resolving the incident');
current.setAbortAction(true);
}
})(current, previous);
Please mark correct/helpful if applicable.
Regards,
Shubham
Shubham Tipnis
ServiceNow Enthusiast
⭐️ 3x Rising Star (2022–2024) – ServiceNow Community
Sharing insights, use cases & real-world learnings from the Now Platform
Always learning. Always building.