Sorting Through Switch Cases Feature Request

Currently, the ‘Switch’ activity does not allow the sorting of cases. That is problematic because if I have 20 to 30 cases and I need to add a new case in a specific position let’s say in case 5, then any case above that will need to be manually cut and pasted into the one below it. Inconvenient and tiresome. I use cases a lot in my automation projects. Hope to see this coming in a future release.

Hi @private_matter ,

I agreed with your problem statement, What I follows , if I have multiple cases then I use conditions so that we can skip the other cases with out cut and paste.


The order of the cases has nothing to do with how it functions. There’s no reason to add them in a specific position.

1 Like

@Ashish_Soni , @postwick

But I don’t want to skip cases. That’s not the point. Let’s take an example to see why sorting is needed. Say I want to build a pricing table for instance that has many features. If let’s say the basic plan contains 20 features and I want to add a new feature but I don’t want to add it at the bottom, I want to add that feature in the third row. Currently, in the cases, we cannot drag and drop the case to the third row which will force me to add a new case at the bottom, and manually cut/paste cases 4 up to 21 in order to only add that single row! And if you’re asking me why I don’t just add regular activities instead of cases, it’s because all the cases have universal activities that the bot needs to do. So for instance, in the pricing table, let’s say I want all the features to have a checkmark next to them. Adding an activity to insert a checkmark for every case is an extra uneeded step. I can add 1 activity only and loop the sequence with repeat number of times activity wrapped around the switch activity. Skipping cases with conditioning is another objective which is not what I’m looking for.

I don’t think you’re understanding. It doesn’t matter what order the cases are in. It will execute the one that matches the Switch condition, no matter what order they’re in.

I don’t think you’re quite understanding what I’m trying to achieve here. I don’t want to pick a single or random choice from one of the cases. The robot has to go chronologically through all the cases. Ex:

Repeat Number of Times (5)

Activity 1 is click
Activity 2 is Switch (Case 1, Case 2, Case 3, Case 4, Case 5)
Activity 3 is TypeInto

Bot executes activity 1, then does Case 1, then activity 3, then loops again, does activity 1, then does Case 2, then does activity 3, and so on…

Again, the order of the Cases in your Switch doesn’t matter. It executes whichever Case matches the expression.


It doesn’t matter where the Here Case is, that’s what it will execute because it’s the one that matches the Expression.

I already know what you’re trying to say. But what I’m trying to do here is completely different. Please download the small demo that I did. It’s about the top-visited websites. Suppose I want to set Case 9 which is Amazon to be positioned and opened at first in Case 1. How would that be done? (6.7 KB)

I can’t download files like that. Post screenshots.

Why can’t you download it? You won’t understand much with screenshots.

Restrictions on our systems in our highly regulated environment.

Screenshots will tell me enough about what you’re trying to do, or you could just explain it.

As you can see, let’s suppose I want Case 9 to be positioned in Case 1 so that the bot can execute in chronological order. Currently only possible with manual cut/paste which can take more than a minute. If sorting was available, this would have taken 1 second.

If CurrentItem is 9, it’ll process Case 9. Doesn’t matter what order your Cases are in.

Your CurrentItem will go 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 so no matter which order the Cases are shown, it’ll process Case 1 on the first iteration, Case 2 on the second iteration, etc.

I don’t think you understand that what it’s doing is looking at the expression (CurrentItem) and then finding the Case that matches CurrentItem’s value.



Each Case just logs the word, which I matched to the integer of the Case.

Here is the output:


I know that the CurrentItem will go 1,2,3,4,5,6,7,8,9,10, process Case 1 on the first iteration then Case 2 on the second iteration. I already know that but that’s not the issue. What I’m saying is that sometimes you want all the activities in Case 9 to be repositioned in another place. Here’s an example list:

-Case 1 includes TypeInto activity with
-Case 2 includes TypeInto activity with
-Case 3 includes TypeInto activity with
-Case 4 includes TypeInto activity with
-Case 5 includes TypeInto activity with

If I leave it in this fashion it will run each item starting from eBay and end with converse. But what if I want the bot to do the following:

-Case 1 includes TypeInto activity with
-Case 2 includes TypeInto activity with
-Case 3 includes TypeInto activity with
-Case 4 includes TypeInto activity with
-Case 5 includes TypeInto activity with

As you can see, to change the position of and set it in Case 2, I need to move Cases 3,4, and 5 down to one position below.

Hope you get what I mean.

Change your Case values, then. Change the Case with value 2 to 3, etc.

But that is still too much input. If I change the value for Case 2, I would have to also change the case value for every other Case underneath it. What if I have 40 to 50 cases? This is not a convenient solution in the least bit. Sorting is necessary. It should be just like they did with the Multiple Assign activity. I will not mark this as solved.

Sorting has NO EFFECT on which Case it executes.

ONLY THE CASE VALUE (compared to the expresssion) affects which Case it executes.

Changing the order of the Cases does nothing. It will still execute the Case with value 2 if CurrentItem is 2, whether that Case is first, last, or anywhere else in the order.

When you use the analogy with multiple assign: Moving the Case 9 to the first position would not change the case value, it would be still 9 but at first “row”.

You rather expect to move Case 9 AND recalculate case values so that 9->1, 1->2, 2->3…

I suppose there is more simple solution:
1/ make array of steps in appropriate order, e.g. steps = {1,2,3,4,5,6,7,8,9}
2/ use CurrentItem to pick value from the array and execute respective “case”, i.e. steps(CurrentItem)
3/ to move step just reorder values in the array, e.g. steps = {9,1,2,3,4,5,6,7,8} will execute step 9 as first step
4/ to add new step just add new case to switch and case value to appropriate position in the array, e.g. steps = {9,1,2,3,10,4,5,6,7,8} will execute case 10 as fifth step


1 Like