Switch Task
The switch
task is used to execute a set of tasks based on the value of an expression.
Switch Task structure
Example of Switch task step.:
task: "switch"
description: "Switch task"
cases:
- when: "[order.status] = 'Pending'"
steps:
- task: "Order/Update@1"
inputs:
orderId: "{{order.id}}"
order:
statusName: "Shipped"
- when: "[order.status] = 'Approved'"
steps:
- task: "Order/Update@1"
inputs:
orderId: "{{order.id}}"
order:
statusName: "Shipped"
default:
- task: "Order/Update@1"
inputs:
orderId: "{{order.id}}"
order:
statusName: "Rejected"
The Switch activity is a YAML object. The Switch activity has the following keys:
- cases (required) - The Cases key is a list of cases that should be evaluated. Must have at least one case.
- default (optional) - The Default key is a list of actions that should be taken if no case is matched. The Default key is optional.