Switch Case with Variable at "Case"

Hello,
I have read the documentation of the activity ‘Switch’ and know that I have first to define the type of input.
For my needs I select “string”. Now I want to iterate with “ForEach” over an array of strings.
The result is this:
grafik

At this point I run into a problem. I can use a default value at this point but I cannot use a variable that I want to be evaluated and the value of the variable compared to the string value.
As far as I know until now I have to know every value that can occur at this place first before I can use this activity.
May be that I’m missing something, but can someone show me a solution to the problem?

Thanks in advance
MartinN

Hi,

We cannot set variable in Case. However, the following expression in Expression property helps switch dynamically.

img20200629-1

Regards,

5 Likes

Thanks for your answer. Yes, I can use this as workaround.

But in my opinion this is activity is not complete and can only be used rudimentarily.
For example: In C# it is defined that each case label defines a pattern that is compared to the match expression. This means that in C# it is possible to use complex objects at that point. I don’t want to ask for this entirely, but a little bit more flexibility would be welcome.

4 Likes

What is the best way to make this issue more known? 2 years later and this recommended change to make the switch statement more robust by providing the ability to use variables in cases has still not been made.

3 Likes

Excellent idea!!! my knowledge is unlocked.