How to Prevent Z Task Closure if X and Y Tasks Are Still Open?

beycos
Tera Contributor

Hello Community,

I’m designing a flow in ServiceNow where I have three tasks using do the following in Parallel. (see screenshot)

  1. (x)
  2. (y)
  3. (z)

The z task cannot be closed unless either  x or y tasks are in the " Close Complete" state. If either x or y  tasks are still open , the "Close Task" button for the  (z) task should be disabled.

How can I implement this in ServiceNow? Should I use a UI Action, Business Rule, or flow for this?

Thanks in advance for your help!

Regards,

Beyza 

2 ACCEPTED SOLUTIONS

Runjay Patel
Giga Sage

Hi @beycos ,

 

You can create before business rule on task table and use below script.

    var grTask = new GlideRecord('task'); // Replace 'task' with the appropriate table name
    grTask.addEncodedQuery('parent='+current.parent+'^stateIN-5,1,2^sys_id!='+current.sys_id+''); // Fetch tasks X and Y
	
    grTask.query();

    if (grTask.next()) {
        gs.addErrorMessage('Task Z cannot be closed until either Task X or Task Y is in the "Close Complete" state.');
  
		current.setAbortAction(true);
    }

When to run condition

RunjayPatel_0-1736229975644.png

 

-------------------------------------------------------------------------

If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.


Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay

-------------------------------------------------------------------------

 

View solution in original post

@beycos 

are you sure the group names are correct?

BR should be before update

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

View solution in original post

11 REPLIES 11

Thank you for your help. Is there a way to do this with Flow instead of BR?

Regards, 

Beyza

beycos
Tera Contributor

Thank you very much for your help. I created a similar BR, and it is now working.br.png Is there a way to do this with Flow instead of BR?