Switch Activity with variable equal Instead of IF Activity

GAS is Array()

IF GAS(0).exist=Y,Go activity AA
IF GAS(1).exist=Y,Go activity BB
IF GAS(2).exist=Y,Go activity CC
IF GAS(3).exist=Y,Go activity CC

How to use Switch Activity if Case Value = 0 or 1 or 2 or 3? What Expression enter?

Is possible that multiple GAS(x) will have the value “Y”?

Cheers

Hello @scorpialee,

You need to use a for loop to loop through the items present in the Array. (Item type String)
Use switch block inside for loop and Pass the Item for condition, check if the item matches to the required value
image

Regards,
Rohith

2 Likes

A few things are unclear but let’s start and let’s look to other techniqes

CheckMasks:

Maybe you can show us more details from GAS array e.g. by immediate panel output
Understanding the 6 Debugging Panels of UiPath in the easiest way possible! - News / Tutorials - UiPath Community Forum

Also have a look here:
grafik

Single() can be used to ensure that 1 and only 1 item is found
FindIndex is taking the first found index

Hi

Please check below attached xmal file

sample.xaml (7.3 KB)

Regards,
Dhanush

My company’s Database feedback GAS(i).exist , i=0~3
And only one equals “Y”,the other equals “N”
And I want to:
GAS(0).exist=Y & GAS(1).exist=N & GAS(2).exist=N & GAS(3).exist=N Go activity AA
GAS(0).exist=N & GAS(1).exist=Y & GAS(2).exist=N & GAS(3).exist=N Go activity BB
GAS(0).exist=N & GAS(1).exist=N & GAS(2).exist=Y & GAS(3).exist=N Go activity CC

Hi,

I’m not sure Which type GAS is, however the following will work as you expect, i think. Can you try this?

If exist method return String type “Y” or “N”

GAS.Select(Function(v,i) if(v.exist="Y",i,-1)).Where(Function(i) i>=0).SingleOrDefault

Or, if exist method return boolean (true / false) , the following condition works.

GAS.Select(Function(v,i) if(v.exist,i,-1)).Where(Function(i) i>=0).SingleOrDefault

image

Regards,

1 Like

Then the last expression proposed by @ppr would be the best option.

Cheers

1 Like

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