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

MOHAMEDYASA
Giga Contributor

how to prevent it using flow????

7 REPLIES 7

yashkamde
Tera Guru

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
Kilo 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