We have a use-case where we Split-out list of objects in the main workflow and trigger sub-worflow for each item in the list.
Sub-worflow has Wait nodes defined which waits for user approvals to proceed further.
In this case, main workflow resumes once the any one sub-workflow completes. We are looking for a solution where main workflow waits for all the sub-workflows and provide us the combined results from all the sub-workflows
What is the error message (if any)?
Please share your workflow
(Select the nodes on your canvas and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow.)
Actually, the logic is not very good, as if the user misses Approving/Rejecting any of the items, the whole workflow won’t finish.
More reliable logic would be to not wait for the sub workflows at all. Instead, do the following:
Save all item ids in the data table with columns like itemId, isApproved (do not fill it yet), parentExecId (the execution id of the main workflow, available by calling {{ $execution.id }}), then pass all items to the sub approving WF in the for-each mode
In each sub WF approve/reject flow, wait for the corresponding action and set a timeout for waiting.
When the approve/reject/timeout happens, update the DT entity for that itemId and call the final WF (or create a check if all items were processed and then call the final WF once all items are finished)
In the final WF, check if all items of the parentExecId were processed (has either isApproved: false or true) and do the ending logic. Then remove the processed entries from the Data Table
To get a combined result from all items, you need to change the pattern.
Either remove the Wait nodes to keep everything synchronous, so the main workflow can truly wait for all sub-workflows to finish, or embrace the asynchronous model and have each sub-workflow write its result to an external store (database or table). Then use a separate consolidation workflow to read all those records and build the final aggregated result.
Thank you @barn4k@tamy.santos
Yes, with external storage for the sub-workflows status works. Just want to check on any in-built support within the parent-child workflows.