Type Switch

The Type Switch control allows you to create different branches in the workflow of your automation, depending on the type of variable.

Using the Type Switch Control

In this example, the Type Switch control is used in the On Error flow to create different branches and sequences of steps depending on the type of error. For more information on the On Error flow, see On Error Handling Workflow.

Procedure
  1. Create an automation and add the Open Excel Instance, Add Workbook and Set Values (Cells) activities.

  2. Click the Set Values (Cells) activity and set a wrong cell value in the rangeDefinition field to raise an error when testing your automation.

  3. Click the Error tab at the top of canvas.

    The On Error node appears.

  4. In your automation, on the right-hand side panel, go to the Tools section and click Controls.

  5. Drag and drop the Type Switch control into the workflow of the automation.

  6. Select the Type Switch control in your automation flow. The Type Switch side panel appears.

  7. Select a variable or enter an expression using the Expression Editor in the Type Switch Expression field.

  8. Select the InvalidRangeDefinition error from the Cases dropdown list depending on the type of error under Cases.

  9. Add a Log Message activity on this branch.

  10. Click the Log Message activity and enter Excel Error in the message field.

    If an error related to an invalid range definition is raised by the automation, you will see the Excel Error message in the console.

  11. Add a Log Message activity on the default branch and enter Other Error in the message field.

    If another type of error is raised by your automation, you will see the Other Error message in the console.

Result

Depending on the type of error that will be raised from the automation, you will get a different message.