Switch Case using .Contains() is not executing as expected

Hello, I am attempting to use switch case to choose a path of action based on a string value. In this automation, “AppName” is extracted from a service ticket and is usually structured as “[application]-APP”. The name of the application is listed, but there is sometimes surround text, like “-APP”. This is not always the case, so instead of manipulating the string, I just want to check if the string contains the name of an app.

I am not getting any errors, it is just not executing as expected. I am using the message box statement to confirm that AppName = “PEOPLESOFT-APP”, yet the switch case always goes to the default case. What am I doing wrong?

we cannot use statemens / variables within the case definitions

What would be a better way to determine flow of the automation based on the value of AppName?

to solve the case we can define a mapping logic which will return a discrete value and then use this for the case definition

Statement is scoped to the switch activity and exclude other options e.g. invoke code additional offered capabilities

Thank you for this, are you able to share any documentation relating to this process? The concept makes sense but I have never had to implement such a thing in Studio, I have only been working in RPA for a few months.

Could I use something as simple as a dictionary variable for this?

@louiemed

you can use an else if activity directly

cheers

Variable: arrLK | DataType: String Array)

Assign Activity
arrLK = new String(){"PEOPLESOFT","HEXAGON"} … add also the other values

Switch Activity Expression

arrLK.Where(Function (x) appName.toUpper().contains(x)).FirstOrDefault("UNDEFINED")

Verification: