Flow - How to properly wait for ALL sc_task records to be completed?

G24
Kilo Sage

Hello Gurus.  Can someone please give me a COMPLETE and DETAILED solution for the following common problem?

 

I have a flow.  In the flow various service catalog Tasks are automatically generated.  And maybe while working on those tasks, some users MANUALLY generate some additional service catalog tasks.

 

At the end of the flow, if ALL TASKS ARE CLOSED, I want to update my sc_req_item state.  I should do that, right?

 

Question

What is the Standard / Proper / Elegant way to achieve this?  I'm having trouble finding a complete solution.  I see a complex business rule here .  I think it is an "After Update" business rule on the sc_task table...  But WHY do I have to drop out of the Flow and use a Business Rule???  Then it seems like future developers will be wondering how items are magically getting closed.

 

Wouldn't it be better to have a Flow Action of some sort, so everything is clear and visible IN the flow?  Has anyone created such an action, and if so, could you share please?  Or if that is a bad way of doing things, can someone please explain WHY Flow itself cannot be used to model this?  Thanks!!

2 ACCEPTED SOLUTIONS

Peter Bodelier
Giga Sage

Hi @G24,

 

Create a subflow.

Input: RITM (reference to sc_re_item)

Output : Active found True / false (default is true)

 

Action Look up Record on sc_task table, active is true, ritm is current ritm.

 

- If any active task found,

   Create wait for condition, active of that task is false.

   End flow

 

If no task found set Output Active found to false.

 

In your main flow after you have finished with your automic tasks and logic:
Create a do the following until.

Call the subflow in it.

Do the following until condition : subflow output Active found is false.

 

After that proceed with closing the ritm.


Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.

View solution in original post

G24
Kilo Sage

Building on what was proposed by @Peter Bodelier solution is as follows:

 

Create a reusable "Gather Task Status" SubFlow which can be reused and will either 1) WAIT on an unfinished task if one exists, or 2) Return a flag indicating that all tasks were in fact completed.  I added some integers also, to indicate how many Complete, Incomplete, and Skipped tasks there were, but that is icing on the cake, and could be skipped.

 

The overall subflow looks like this:

00.png

The inputs and outputs look like this:

InputsAndOutputs.png

Individual flow actions look as follows:

01.png02.png03.png04.png

05.png

06.png07.png08.png

09.png10.png11.png12.png

13.png14.png

 

The subflow is used inside of a regular Catalog flow as follows:

MainFlow.png

The details of those Flow actions are as follows:

19.png20.png21.png22.png

 

Then at runtime, after all tasks are closed Closed Complete, Closed Incomplete, or Closed Skipped, like this:

Tasks.png

 

The Catalog Item will be closed, like this.  Woohoo! ...

Result.png

 

Optional updating of comment field looks as follows:

CommentField.png

 

The End.  Please mark helpful if this helped you in some way!

View solution in original post

15 REPLIES 15

I must be missing something here as I tried to implement this and the 'Do the following' just kept looping until it hit some kind of maximum attempts and the Flow errored out. 

 

What's preventing your solution from just constantly running as long as there is at least 1 active Catalog Task like mine is?

Hi @Shane J 
I have gone through this article. While I am trying this, I encountered with same issue as yours. 'Do the following' just kept looping until it hit some kind of maximum attempts and the Flow errored out.

Did you got any solution for this. Am I missing something here?
Please let me know if there is any solution. 
Thank you

@VullankiL  We haven't made a habit of doing this in Flow like we did in Workflow so it took awhile to find an example, but I think the following series of steps works as of Vancouver (we're now on Xanadu).  In the first screen shot, note the 3 second Wait for, if I recall correctly that prevented an issue.

ShaneJ_0-1735912106023.pngShaneJ_1-1735912141932.pngShaneJ_2-1735912183203.png

 

 

 

Ramesh2
Tera Guru

Nicolas_B
Tera Contributor

Hi,

 

I can see a risk in the Flow proposed unless I'm mistaken.   This flow will continuously runs as long as the tasks are pending right ?   It will run on the platform scheduler and potentially clog up your queue and the other flows will be impacted.

 

Why not create a Flow that is triggered on the sc_task status update (similar to an "On Update" Business rule) so that when a Task is closed, it will check if there are still other tasks and if not, close the RITM.   This would run quickly once when a task is updated instead of making a loop checking constantly if the task of a particular RITM is closed.

 

Regards,