Welcome back to Fun Fact Friday! In this installment, we will be talking about the new Run Other Workflow step type.
This one has been in the works for a while now. It is one of the most challenging step types to create. Let me explain to you where the challenges come from and what solutions we've thought about.
Do you want the latest or the one that works?
One big challenge comes from that dilemma. One great advantage of Koupi is also one of its major drawbacks: you can run the latest version of a workflow. The difficulty with this is that, as the workflow changes, it is possible to introduce breaking changes.
Downloading a workflow
If you want to download the latest version at run time all the time, your best bet is to use a public workflow since those are tested, approved, and not modifiable without prior approval. That being said, they can break, especially if they download things from the internet.
If you want to download a know, working version of a private workflow, what is the solution there? Create a non-editable copy of the workflow in the database? Save the generated code in the workflow? How does that scale with the number of workflows using them? The answer is: not well.
The next question is: how do we handle nested workflows (workflows requiring other workflows)? The more nested workflows there are, the harder it becomes to handle them all... Also, what happens if a loop (workflow A requires workflow B, and workflow B requires Workflow A) is introduced?
Lastly, how do we give you the ability to download the script version of the workflow that contains other workflows? There are so many use cases; which one is the right one for you?
Given that there was no right answer to any of the questions above, we decided to go with the easiest one and see how it goes.
The easiest answer is: Workflows will be downloaded anew if they haven't already been downloaded. Also, Koupi will not be looking for loops in the workflows for now.
What does this look like?
The code will follow this basic workflow:
1) Is there an existing child workflow file in the same folder as the current one?
2) If not, download it.
3) Run the child workflow.
The advantage of this solution is that it allows you to run a workflow in two ways: download the latest version every time and run a known version.
I'll add pictures to this post once it's ready and fully tested.
In the meantime, see you next week for another episode of Fun Fact Friday!