Switch case expression syntaxis help

Dear UiPath’s friends
I would like to have your advices regarding this issue:
I need to make a Switch activity expression to verify if it matches with the subfolder names just to be able to direct instructions.

First at all, my inbox is composed by two folders (Converters and Warehouse)
then the folder converters has a subfolder: ATCP
And the folder warehouse has also a subfolder : CDWC

As you see in the picture below:

1.- My first activity is an Assign (ListSubfolders = New List(Of String) From {“Inbox\Converters\ATCP”, “Inbox\Warehouse\CDWC”,“Default”))
2.- Second activity is a For each (currentFolder = ListSubfolders)
3.- inside For each activity the expression i use is:

Capture27

If(currentFolder.tolower.Contains(“atcp”),“ATCP”,

If(currentFolder.tolower.Contains(“cdwc”),“CDWC”,

“Default”))

I would like to know how to make “the switch expression” works because it can’t direct to the Switch cases …

are the expression : Correct?

If(currentFolder.tolower.Contains(“atcp”),“ATCP”,

If(currentFolder.tolower.Contains(“cdwc”),“CDWC”,

Thanks in advance…

Hi @Ricchch ,

Could you let us know what does happen with the current implementation ? Does it move to the Default instead of the ATCP or CDWDC folder ?

1 Like

Hello @supermanPunch and thanks

Yes, it goes directly to Default Case…eventhough it should go to case ATCP or CDWC folder…
Thanks for helping

Yes, it goes to Default case , even though it should go to ATCP or CDWC cases.
Thanks for any help

we can also rewrite into a less nested if way

new String(){"ATCP","CDWC"}.Where(Function (x) currentFolder.toUpper.Contains(x)).DefaultIfEmpty("Default").First()

for sure we would debug / trace and prototype if needed:
Understanding the 6 Debugging Panels of UiPath in the easiest way possible! - News / Tutorials - UiPath Community Forum

1 Like

Hello @ppr and thanks for helping

i wrote your suggestions as it is shown in the picture below , but it went also to Default case

Thanks for any help

  • typeargument of the for each activity is set to string and it is checked
  • Debug & trace the flow with the debugging panels as presented in the shared link from above

Yes Type argument is String type:

image

Do i have to check the Private case?
Thanks :handshake:

I have the same result even when checking the private case
image

NO

It is up to you, but debugging is the Best-Practice approach for analysis (stepwise, step in…) and highly recommended

Thanks ,
I will try to debug
handshake: