Minimize use of Nested IF condition

Hi everyone,

My requirement to reduce the usage of nested or multiple if else conditions

I have an array of files , so i am using for each inside that using if condition

  1. file.contains(“Info”) then assign its full path to variable (mainPath)
    In Else part:
    similarly 2. file.contains(“relation”) then assign its full path to another variable (relationPath)
    final else
    1. file.contains(“leave”) then assign its full path to another variable (leavePath)

Thanks in advance


you can use Switch Activity for reducing the Nested IF


1 Like

Hi @kavya.s16

May be u can try this:
assume file is the variable u want to check against condition


store the keys in array variable (string)

arrkeys= dict1.Keys.ToArray()

Now use an if condition like this with condition like this

arrkeys.Where(Function(m) file.Contains(m)).Count<>0

if this condition is True, then

use the following assign activity to get the corresponding key from dict_1

key= arrkeys.Where(Function(m) file.Contains(m))(0)

then once u get the corresponding key, u can get the corresponding variable value u need by dict_1(key)

Hope this help :slight_smile:

Mark it as soln if it helps !!!

Thanks & Regards,
Nived N

1 Like

Hi @kavya.s16

If ur issue is resolved , kindly mark the appropriate answer as solution

U can use one of the newer activities called “else if”:

It allows to set several conditions. Activity checks condtions from the top. If any is met as true, then body is done and else if is finishing checking the others.


Try user the switch activity.