Switch Block
Nected's Switch Block is a control node available exclusively in the workflow editor. It allows users to define multiple execution paths based on specific conditions, thereby providing flexibility and precision in workflow management. This document provides a comprehensive guide on how to add and configure the Switch Block in your workflows.
In traditional workflow setups, multiple conditions need to be evaluated and acted upon independently.
The Switch Block introduces conditional flow just like the Switch case inside workflows, which helps address the inefficiencies of sequential flow. Here’s how the Switch Block solves these problems:
Conditional Execution: By defining multiple paths based on conditions, the Switch Block allows different parts of the workflow to run simultaneously. This reduces waiting time and increases overall efficiency.
Simplified Workflow Management: Conditions and actions are separated into different paths, making the workflow easier to understand, maintain, and debug.
With conditional execution, flows are utilized more effectively, as independent tasks can be processed concurrently.
Steps to Add and Configure the Switch Block:
To effectively utilize the Switch Block in your workflow, you'll need to follow a few straightforward steps. The process is intuitive, ensuring that you can quickly set up and manage complex workflows with conditional execution paths like switch-case, enhancing both flexibility and efficiency. Below, you'll find detailed instructions on how to add and configure the Switch Block within your workflow.
Adding the Switch Block
To add a Switch Block to your workflow, follow these steps:
Navigate to the Workflow Screen: Go to the workflow page where your workflows are listed.
Select a Workflow: Click on the workflow you wish to edit. This will open the workflow editor.
Add Switch Block: In the workflow editor, locate the option to add a new block. Select the Switch Block from the list of available blocks.
And you’re done. Now, the switch block will help you to make multiple condition-based outcomes in your workflow.
Configuring the Switch Block
Once the Switch Block is added to your workflow, you need to configure it by defining conditions and corresponding actions. Here’s how to do it:
Input Params:
In the Switch Block configuration panel, go to the “Input Params” tab.
Before specifying the conditions specify the paths of execution like this:
Define Paths:
Each path represents a different case in the switch-case statement.
Unique Path Names: Ensure that each path within the same Switch Block has a unique name. However, paths in different Switch Blocks can have the same name, even if nested within each other.
To change the sequence of a PATH, just click on the button. And can figure out, the execution path of the function
Default Path: In the same Input Params tab, you can see the Default option at the bottom. The purpose of the default is the same as we see in the switch case. It will execute the default path if all conditions in other paths are not satisfied.
It is optional. You can define a default path that will be executed if none of the specified conditions are met. And if the option is off, there will be no default path for the case, if no other conditions are met. This ensures that the workflow always has a defined behavior and doesn’t break its flow. If the default option is turned off then the switch block will return the response only if no conditions are met.
Then once the path is created, now create the conditions that will determine the execution path. Conditions can be based on various parameters such as data values, states, or external inputs. You can define conditions using parameters like
action.action
,additionalOutput
, andoutput
. While adding the conditions, you can create nested conditions as well to add multiple constraints. To do so, you just need to click on the "+Add Group" button to create a new group. Or you can click "+Convert to group" to convert the current condition in a group. As shown below:
Whether you're creating nested conditions or not, you can create up to 10 paths only.
Test Result:
After configuring your Switch Block in the Input Params tab, click on the “Test” button below the panel, and the Test result tab will open to test your configured switch block.
Settings:
In the Settings tab, there is an option to set the “timeout after” to simply set the timeout time of the switch block.
Set Actions:
To set Actions, close the configuration panel first, and come back to the editor.
For each path that you’ve created, click on the + button to add the actions to be taken if the condition is met.
As Actions, you can again add any node including another Switch Block.
Troubleshooting Guide
Now, here is the troubleshooting guide, in case you missed anything
Common Issues and Solutions
Condition Not Met:
Issue: The expected path is not being executed.
Solution: Double-check the condition definitions in the Switch Block configuration panel. Ensure that the parameters and values are correctly specified.
Default Path Not Executed:
Issue: The default path is not being triggered when conditions are not met.
Solution: Verify that the default path toggle is enabled in the Switch Block configuration panel.
Configuration Not Saved:
Issue: Changes made to the Switch Block configuration are not being saved.
Solution: After configuring the conditions and actions, ensure you click the "Save" button in the configuration panel.
Unexpected Behavior:
Issue: The workflow behaves unexpectedly after adding the Switch Block.
Solution: Review the entire workflow to ensure that the Switch Block and all other blocks are correctly configured and connected.
Conclusion
The Switch Block feature in Nected provides a versatile way to control the flow of workflows based on specified conditions. By following this guide, you can effectively implement and utilize Switch Blocks to enhance your workflow management processes, ensuring flexibility and precision.
By referring to the attached images and following the troubleshooting guide, you can resolve common issues and ensure the smooth operation of your workflows with Switch Blocks.
Last updated