Prevent Incident Closure if Child Task is Active

Kusuma Sai
Mega Guru

Hi,

If related child 'Incident_task' is Active, prevent the Incident Resolved/Closed.

tried with Before BR and Script Include and OnSubmit CS also, but not working as expected- suggest

KusumaSai_0-1749815259324.png

 

KusumaSai_1-1749815326928.png

KusumaSai_2-1749815367768.png

 

 


 @Ankur Bawiskar 

 

1 ACCEPTED SOLUTION

prudhviraj1
Tera Guru

Hi @Kusuma Sai ,

 

Try to use Before Update BR only.

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

 

var gr = new GlideRecord('incident_task');

gr.addQuery('active','true');

gr.addQuery('incident',current.sys_id);

gr.query();

if (gr.next()) {

   gs.addInfoMessage('This Incident cannot be resolved as there is or are active child Incident Tasks. Please close them first');

current.incident_state = previous.incident_state; 

   current.state = previous.state;

   current.setAbortAction(true);

   gs.setRedirect(current);

}

 

})(current, previous);

View solution in original post

14 REPLIES 14

Ankur Bawiskar
Tera Patron
Tera Patron

@Kusuma Sai 

are you querying with correct field? incident or parent at line 5

what debugging did you do?

Only before update business rule is sufficient, why to have script include and onSubmit?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

'incident' only sir

KusumaSai_0-1749815513136.png

 

@Kusuma Sai 

what debugging did you do?

did you add gs.info() in your BR and see if it ran?

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Ankur Bawiskartried sir, but not helping anything
what i have to added here sir? Incident Task > Incident or Incident Task Parent ?

KusumaSai_0-1749818045799.png

 

KusumaSai_1-1749817749964.png

 



KusumaSai_0-1749817720691.png