Add a "switch" node for workflows

AI-generated summary

mcwumbly proposes adding a “switch” node to workflows to simplify branching logic for different input types. Currently, to handle various inputs with the same processing logic, the user employs a code node to normalize a configuration object, allowing downstream steps to reference variables consistently. Initially, this involved connecting separate scheduled triggers for each input type, but managing the schedules for longer-running jobs became cumbersome. Consequently, the user migrated to using a data table for schedule management, which resulted in a workflow filled with chained “If” nodes to route execution based on the input type. The proposed “switch” node would allow defining multiple “case” statements, each directing the flow to a distinct branch, thereby improving readability and maintainability compared to nested conditional checks.

I have a workflow where I want to do the same thing, but for different kinds of inputs.

My approach has been to use a code node that has a simple configuration object, which is then normalized through another code node, so that downstream references can use the same name, like var vars = $('run vars').first().json

Initially, I had been wiring them each up to a scheduled trigger, kind of like this:

But then it got a bit tiresome to think about what each of the schedules should be, especially when there are some longer running jobs for each. So I moved to a data table to manage that part. But in the process, I have had to make this small compromise, with a bunch of chained “Ifs”:

I’d love to have something like a “switch” node, where I could have multiple “case” statements that each output to a different branch.

1 like