We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

How to prevent users from closing an Incident if there are active Child Tasks?

MOHAMEDYASA
Tera Contributor

how to prevent it using flow????

9 REPLIES 9

BharatC
Tera Contributor

Hello @MOHAMEDYASA ,

 

Using Before business rule is servicenow best practice,

But if you must use the flow then i have attached the screenshots.

 

Please click helpful if this post helped.

yashkamde
Kilo Sage

Hello @MOHAMEDYASA ,

 

No, it is not possible, as Flows are not connected to the UI of the user and his transactions. Therefore, a flow Cannot abort a user transaction.

 

Use Business Rules if you want to do achieve the same.

 

If my response helped mark as helpful and accept the solution.

AshishKM
Kilo Patron

Hi @MOHAMEDYASA , 

The best way to manage this use case at server level and write BR [ update] on incident table and check if there is any other active INC exist with the current INC added as parent, if record found then abort the SAVE action else SAVE it.  Refer the code shared by Ankur Bawiskar. 

 

-Thanks,

AshishKM


Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution

Aditya_hublikar
Mega Sage

Hello @MOHAMEDYASA ,

 

Buy using flow its not possible , you cant abort form submission using flow designer. You must use script 

(function executeRule(current, previous /*null when async*/ ) {
    var gr = new GlideRecord('incident_task');
    gr.addQuery('incident', current.sys_id);
    gr.query();
    while (gr.next()) {
        if (gr.state != 4 && gr.state != 3 && gr.state != 7) {
            gs.addErrorMessage("Please close all incident tasks first!!");
            current.setAbortAction(true);
            break; // stop loop once condition met
        }
    }

    // Add your code here

})(current, previous);

 like 

 

like  above Business rule .

 

Conditions :

state changes to resolved  or

state changes to closed

 

 

If this helps you then mark it as helpful and accept as solution.

Regards,

Aditya,

Technical Consultant

 

Willie23
Mega Contributor