Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

Incident should not resolved if any task are pending or open. once all the tasks are closed then only Incident can close/Resolved.

Veera raju
Tera Expert

Hi,

Incident should not resolved if any task are pending or open. once all the tasks are closed then only Incident can close/Resolved.

For example: 

In an Incident there are 3 tasks are there if 2 tasks are closed and one is open/pending then if i close that incident it will not going to close.

Once all the tasks are closed then only Incident is get closed.

 

Please help me on the same.

1 ACCEPTED SOLUTION

Hi, 

Try with below code

(function executeRule(current, previous /*null when async*/) {

// Add your code here
var gr=new GlideRecord('incident_task');
gr.addQuery('incident',current.sys_id);
gr.addQuery('active',true);
gr.query();
if(gr.next())
{

current.setAbortAction(true);
gs.addInfoMessage("incident can not be closed untill all incident tasks should be closed or resolved");

}

}

Regards,

Pooja

View solution in original post

8 REPLIES 8

Hi, 

Try with below code

(function executeRule(current, previous /*null when async*/) {

// Add your code here
var gr=new GlideRecord('incident_task');
gr.addQuery('incident',current.sys_id);
gr.addQuery('active',true);
gr.query();
if(gr.next())
{

current.setAbortAction(true);
gs.addInfoMessage("incident can not be closed untill all incident tasks should be closed or resolved");

}

}

Regards,

Pooja

Yes above updated code is working fine.

Thank you...pooja

 

Regards,

i have wrote the same code but my incident is being closed again and again what to do

 

Navneet3
Tera Expert

Hi, I created a new BR and used the above script but something is wrong. The Incident still gets resolved. Here are the screen shots.

Thank you in Advance.

 

find_real_file.png

find_real_file.png

 

find_real_file.png