Building for Scale: Use Map Value for Data Mapping, Not Switch

Across the many years in process automation, I’ve seen one pattern emerge repeatedly: a solution that works for a specific case is often stretched beyond its intended purpose, creating future complexity and technical debt. In Zenphi, this anti-pattern often involves the overuse of the Switch action for simple value mapping.

While this approach is intuitive, it can lead to brittle, hard-to-manage flows. Building robust, enterprise-grade automations requires using the right tool for the job. This is a core principle for maximizing the long-term value of your processes.

The Switch Action: For Branching Logic

First, let me be clear: the Switch action is powerful and essential. Its purpose is to direct a flow down different paths, executing a unique set of actions for each branch.

Think of it as a logistics manager:

  • If a request is for ‘IT Hardware,’ the flow branches to a series of actions involving procurement and inventory checks.

  • If the request is for ‘HR Onboarding,’ the flow branches to a different set of actions for account creation and document generation.

When your process requires executing different sequences of actions based on a condition, Switch is the correct and necessary tool. The problem arises when we use this powerful tool for a much simpler task: assigning a value based on an input.

The Map Value Action: For Branching Data

When your only goal is to look up a corresponding value—for example, assigning a support ticket to the right person based on its category—there is a superior tool: the Map Value action.

This action was designed specifically for this task. It functions like a simple, highly efficient translation dictionary. You provide an input, and it returns the corresponding output from a list you define.

Example

Let's compare the two methods for a ticket assignment scenario.

The Goal: Assign an owner's email address based on the ticket category.

The Anti-Pattern: Using a Switch Action To accomplish this with Switch, you would need to:

  1. Add a Switch action with a branch for each category (Billing, Technical, Sales, etc.).

  2. Inside each branch, add a Set Variable action to assign the correct email address.

  3. As you add more categories, you must add more branches and more Set Variable actions.

  4. If you exceed 10 categories, you must nest another Switch action, making the flow complex and difficult to read.

The Best Practice: Using a Map Value Action With Map Value, the process is far simpler:

  1. Add a single Map Value action.

  2. Configure all your mappings inside this one action:

  3. The action outputs the correct email, which a single, subsequent step can then use.

Your flow remains flat, readable, and easy to maintain. You have avoided the future cost of managing unnecessary complexity.

The action outputs the correct ticket handler’s email, which a single, subsequent step can then use. Your flow remains flat, readable, and easy to maintain. You have avoided the future cost of managing unnecessary complexity.

The Summary

My Recommendation

To ensure your automated processes remain an asset and not a liability, adopt this best practice:

  • If your goal is simply to determine a value for a variable, always use the Map Value action. It will make your flows more professional, scalable, and maintainable.

  • Reserve the Switch action for its intended purpose: branching the logic of your flow to execute different combinations of actions.

I encourage you to look at your existing flows. Identifying and refactoring a Switch into a Map Value action is a simple investment that will pay dividends in clarity and reliability.

You are not just fixing a flow; you are adopting a principle of professional automation design.