Nested IF vs Switch

Hi All,

I am automating different types of PDF files. Based on the Page title, reading content will change. Currently, I am using Nested if for this.

In IF activity, am writing following expression: PDFText.Contains(“Export Bill Realisation - Advice”) and in else part PDFText.Contains(“Debit - Advice”) and so on… and also am getting exact solution by this approach but there are total of 15 types of PDF files. If I will follow this approach then I have to write 15 IF activities one inside another.

Is it possible to convert it to Switch activity ? If yes, what I have to write in expression field and cases. Could you please help me in this.

For this approach, which one is better Nested IF or switch ?

Thanks & Regards,
Lakshman Ganta.

The better way to do this is,

Use Invoke Code activity, and write the if else logic inside this activity and assign the matching string to one variable.


If( PDFText.Contains(“Export Bill Realisation - Advice”))Then
strvar = “Export Bill Realisation - Advice”
'statement(s) will execute if the Boolean expression is false

End If

Let say, after invoke code activity, you have a matched string in strvar

In the switch activity,

Expression: strvar
case1: Export Bill Realisation - Advice
case2: Debit - Advice

Hi @KarthikByggari,

In this case, I have to write nested IF and switch also right ?

In this case you need just code to assign the right string. It improves your workflow readability.
Because we don’t need if else activities in the main workflow.

Thanks Karthik. Will implement that way. If I have any doubts then will get back to you.

1 Like

Hi KarthikByggari,

Could you please send me sample workflow for this invoke code activity.

Got solution. Thanks for your help.

Hey @KarthikByggari ,

I want to repeat some task based on two conditions. 1 is if the element exist is true and the other one is if attempts<3. For that I have written the following code but the inner if is getting executed only once. Can you please suggest why it is happening

bool=element exist?


    {  atempts<3
then 					else{end execution}
    re execute

bool=element exist?


Sorry!! My bad… it completely wend out of mind that if loop doesn’t repeat itself.
I used while loop to repeat the process and then followed it by a if loop. It worked… :slight_smile:


Hi Lakshman, I’m facing a similar issue. Do you mind sending me a copy of your workflow? I’ve been stuck for days now. Thanks so much! :slight_smile: