- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2023 11:33 PM - edited 05-08-2023 11:59 PM
We are manually resolving the incident ticket ,but can we restrict the incident ticket to not to resolve while incident tasks are in open state /work in progress
Please suggest the best pratices
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-09-2023 12:37 AM
@String Here is the BR which you need to create to restrict the incident from changing the state to Resolved if there associated open/work in progress tasks.
Here is the script.
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var glideIncidentTask = new GlideRecord('incident_task');
glideIncidentTask.addEncodedQuery('incident='+current.sys_id+'^stateIN1,2')
glideIncidentTask.query();
if(glideIncidentTask.hasNext()){
current.setAbortAction(true);
gs.addErrorMessage('This incident has incident tasks which are either in opened or work in progress state.');
}
})(current, previous);
Please mark this answer correct and helpful if it manages to address your requirement.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2023 11:59 PM
Hi,
Yes you can do that, for example by creating a business rule that checks for open task before allowing to change the state to resolved.
But one question;
How will a caller react if they are unable to self-close their incident because it still has open incident tasks (and they can't see the tasks) ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-09-2023 12:08 AM
Hi @OlaN thanks for your quick reply,Can we throw an error window message like ,"so and so Incident tasks are open ,Please check with admin" !

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-09-2023 12:18 AM
In that case I would instead suggest that the business rule only runs for specific roles, such as ITIL-users.
And still allow for callers/end users to have the ability to self-close their incident.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-09-2023 12:28 AM - edited 05-09-2023 12:35 AM
Okay @OlaN am trying the below code in BR but ticket is getting resolved
var sysid = current.sys_id;
var target = new GlideRecord('incident_task');
target.addEncodedQuery("stateIN1,2^incident="+sysid); //1 open 2 wIP
target.query();
if (target.getRowCount() != 0) {
gs.addErrorMessage("Inc Task is open ,So we can't resolve ticket .Please contact admin");
}
Please guide me