Cameron McKenzie
Cameron McKenzie

Reputation: 3880

How to switch on a String in UiPath?

The UiPath Switch Activity defaults to the int32 data type, so you can easily add case statements based on a whole number, integer value. But if you attempt do use a String as the expression, the activity fails.

So how do you create a String switch activity in UiPath Studio?

Upvotes: 1

Views: 2552

Answers (1)

Cameron McKenzie
Cameron McKenzie

Reputation: 3880

While the expression type for a UiPath switch activity defaults to int32, not String, it can be easily changed by opening the Properties tab in UiPath Studio and clicking the drop-down box associated with the TypeArgument attribute.

UiPath String Switch Property

In the UiPath Switch's TypeArgument field, you can set the expression type to String, Object, DataTable, Array of [T] and any other data type you can access through the Browse for Types wizard.

UiPath Switch with String

String, Switch, Cases and Double Qoutes

One interesting aspect of the case statements in a UiPath String switch is the fact that the matching field does not need to be in double quotes. Every other place you reference a String in UiPath, it must be in double quotes. The UiPath string switch activity seems to be one of the few places where the double-quotes requirement disappears. In fact, if you add double quotes, it likely won't work as intended.

Upvotes: 5

Related Questions