ZOHO Flow - Command & Scripts
ZOHO Flow - Command & Scripts
The “Commands & Scripts - Execute Command”
feature in Zoho Flow allows you to execute custom scripts or commands
within your workflow. It is particularly useful for handling advanced
logic, transforming data, or performing operations that are not directly
supported by the standard Flow actions.
Here’s a detailed walk-through of the Execute Command feature and its settings:
Purpose of “Execute Command”
- To transform data: Apply custom logic or calculations to manipulate data before passing it to the next step.
- To create conditional workflows: Execute custom logic to decide what actions to perform based on specific criteria.
- To simplify workflows: Replace multiple Flow actions with a single custom script.
- To handle API requests: Make API calls to third-party services or process data from external systems.
Key Components of the Setup
-
Name:
- Purpose: Specify a name for the command.
- Usage: Helps identify the command within your Flow.
- Example: “Calculate Total Amount” or “Format Customer Data”.
-
Input Fields:
- Purpose: Define the data that the script will use as input.
- Settings:
- Field Name: A name for the input variable (e.g.,
price, quantity). - Data Type: Choose the type of data (
Number, Text, Boolean, Date-Time, or Array).
- Example: For a calculation, you might define:
price (Number)quantity (Number)
-
Command Script:
-
Output Fields:
- Purpose: Define the data returned by the script, which can be used in subsequent Flow steps.
- Settings:
- Field Name: A name for the output variable (e.g.,
total_amount). - Data Type: The type of the returned data (
Number, Text, Boolean, etc.).
- Example:
- Field Name:
total_amount - Data Type:
Number
Step-by-Step Setup Example
Scenario:
You want to calculate the total amount for an order (price × quantity) and pass the result to another step.
Steps:
-
Add the “Execute Command” Action:
- In your Flow, add the Execute Command action.
-
Set Up Input Fields:
- Add two input fields:
price (Number)quantity (Number)
-
Write the Script:
total = input.price * input.quantity;
return {"total_amount": total};
-
Define Output Fields:
-
Use the Output:
- Use the
total_amount output field in subsequent steps (e.g., send it in an email or update a database).
Advanced Examples
Example 1: Conditional Logic
Example 2: API Request
-
Scenario: Make an API call to fetch exchange rates.
-
Script:
url = "https://api.exchangerate-api.com/v4/latest/USD";
response = getUrl(url);
data = response.toJSONList();
return {"exchange_rate": data.get("rates").get(input.currency)};
-
Input Field:
-
Output Field:
Testing the Command
- After defining the input fields, script, and output fields:
- Click on the Test & Save button.
- Provide sample input values to test the script.
- Verify that the output fields return the expected results.
Best Practices
- Use Descriptive Field Names:
- Clearly name your input and output fields for better readability.
- Validate Input:
- Document Your Scripts:
- Add comments in your script for complex logic.
When to Use “Execute Command”
- When standard Flow actions do not support your required logic.
- When integrating external APIs or systems.
- For data transformation tasks like calculations, string manipulations, or custom branching logic.
Further Resources
This approach gives you complete control over your data and workflows, enabling custom logic and integrations.
Related Articles
ZOHO FLOW IN THE BUSINESS LANDSCAPE
ZOHO FLOW IN THE BUSINESS LANDSCAPE Zoho Flow is a powerful integration and automation tool within the Zoho ecosystem. It allows businesses to connect multiple applications, automate workflows, and enhance productivity without requiring extensive ...
Time and Resource Management - Agile Project Management, Service Desk Tickets or Projects
If you find the overwhelm of all the available systems that all seem to do much of the same thing, leaving you with a feeling of inadequacy, and unable to face the technological future, read this to figure out which tools all do roughly the same ...
How to send a comment to the Customer or Ticket Creator
1. Sending a Comment to the Customer or Ticket Creator Zoho Desk allows you to add comments to tickets, and you can choose whether to make these comments public (visible to the customer) or private (visible only to agents). To send a comment to the ...