Using switch that have in 1 case 3 values

Hi everyone
I have a switch case that can get 10 values, that 3 of them will enter to the same case, Example:
the cases will be: 1, 10, 30, 70, 71, 72, 65, 90, 53, 27. and if I will get 70, 71, 72 - they can enter too the same case (so I won’t need to create 3 more cases for the same option) so in the case check it will search for 70 or 71 or 72.
thank you in advance

Hi @dlichtenstadt

If the values varsstring = 1,10, 30, 70, 71, 65, 90, 53, 27 are stored in a string of array
Then split the values using “,” separator, and use a condition for checking the values are equal then take an assign and create a unique variable value for all those values and pass that to switch activity.
If this helps to solve your query then mark it as solution.

The “Switch” activity does not allow multiple values per case (VB “select case” allows this).

You could solve this in two ways:
1/ If it will be only one “case” having multiple values you could use the “default” case.
This is most simple but has potential dark side - any other (not explicitly listed) value will be treated as “default”
2/ Create 3 cases and separate processing logic into a workflow - so you do not need to copy the code 3 times
3/ Use “invoke code” to execute VB “select case” to “group” input values. Following “switch” activity could use this “grouped case”

1 Like

It’s not in a string array
all the values come from a column in an excel file (each row can have a different value)
and all those in the image are for the same sequence (if I will get one of them it will need to do the same code only for one change inside), and if I will get 70,71,72 - again the same code for all 3 except for one activity inside.
what I did is to save the real value in another variable, and in the “real” variable I entered the value “70” so I would know to enter to that section and inside I will use the real value (that is saved inside the other variable)
can u please elaborate on the invoke code (the third option) it seems like a great idea to know?

Here you have the whole sequence.
1/ In_Value is value from the excel
2/ Out_Value is used in “switch” activity

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.