Multible if condition

how to use multiple if conditions with excel for example i have excel file with column name “DFF”
i have done a automation that execute tow workflow if the DFF is empty do this if the not do this.
but now i need to increase the if condition because i have two more workflows depend on the same DFF column.
these are the if conditions that i need to use for the same column.
String.IsNullOrWhiteSpace(CurrentRow(“DFF”).ToString) . this one is if the DFF is empty.

System.Text.RegularExpressions.Regex.IsMatch(CurrentRow(“DFF”).ToString, “^\d+.\d+.\d+$”)
this one is for to check if the column have numbrs like this 10.10.10

System.Text.RegularExpressions.Regex.IsMatch(CurrentRow(“DFF”).ToString, “^\d+.\d+$”)
this one is for to check if the column have numbrs like this 10.10
System.Text.RegularExpressions.Regex.IsMatch(CurrentRow(“DFF”).ToString, “^\d+”)
and this if the value is digits without dots

this is the current IF activity that i need to increase.

Hey @mohamed.saty2012 ,

Add another Else If inside the body of Else to add the second condition.

When you want to test multiple conditions you need to either create a Nested If or Nested Else IF only.

Let me know if you have any further clarifications.

Happy Automating.!!

Thanks,
Gautham.

Thanks I will try this. also, can you work with Regex excretions

Hi @mohamed.saty2012 ,

Try using ,

System.Text.RegularExpressions.Regex.IsMatch(CurrentRow(“DFF”).ToString, “^(?:\s*|(?:(?:\d+.\d+.\d+)|(?:\d+.\d+)|(?:\d+)))$
”)

Thanks,
Gautham.

i will share with you the automation i am working on to get more understanding of what happening with me . the problem is that i can select the first and the second and the third and the fourth digits if they like this 10.10.10.10 but if the it is like this 10…10.10. it get the second value correctly with is null but for the next to digits the bout get them null even if there is values into the Excell cell.
run this automation and you will understand
GL Template.xlsx (11.3 KB)
Test digit extraction.xaml (15.5 KB)

Can you send a screenshot of the packages you are using in the project.?

in the Excell sheet in the DFF column you will see that i have 4 or 5 different scenarios of what the values might looks like

Hi @mohamed.saty2012 ,

I saw your file and I would suggest you to Go with nested if. Which would be easy to design as per your requirement.

Give it a go and let me know if you face any hard time in that approach.

Thanks,
Gautham.

no this is not about the If condition i am simply needed to select the values correctly in these four variables. the next phase will be the if conditions, but it is for another workflow.

Can you elaborate on your problem statement , I understood that you need to check the value under 4 different conditions one after other from the scenario you have explained while you created this post.

But now you are telling if condition is next step.

Sorry am unable to interpret, your exact situation.

the if condition works the same way you have suggested. now inside the if condition i have a workflow. this workflow depends on the values that will be extracted from the automation i have sent to you i will use type into activity to use the four variables, that why i need to correctly get the four values first to enter them separately into the type into activity.

did you see the problem Bro

Hi @mohamed.saty2012 ,

Use an Assign Activity,

LHS - Pattern Based Flag Variable - Type Int32
intFlag

RHS - Nested IF - to check which pattern the value matches with and initiate the Flag Variable
something like below
‘IF(String.IsNullOrWhiteSpace(CurrentRow(“DFF”).ToString),1,IF(System.Text.RegularExpressions.Regex.IsMatch(CurrentRow(“DFF”).ToString, “^\d+.\d+.\d+$”,2,IF(System.Text.RegularExpressions.Regex.IsMatch(CurrentRow(“DFF”).ToString, “^\d+.\d+$”,If(System.Text.RegularExpressions.Regex.IsMatch(CurrentRow(“DFF”).ToString, “^\d+”),4,“UnKnowPattern”)))))’

Once the flag value is set

You can use switch activity set the property to int32, use intFlag in condition and set the actions to be performed corresponding to the Flag value (1/2/3/4)

Hope this would help you out.

Thanks,
Gautham.

ok, but just for now can you tell me why is the automation that i have sent is giving null values even if there is data to extract

also if used regex tester it gives all patterns are getting the correct values.

Actually I couldn’t view the flow, few packages are restricted within the org.

I would suggest you to place multiple break points and Track the value being stored in locals panel or watch window by adding the variable, Also share a snap at the point when you are getting the null value.

The expression you are using is of type ismatch which would return boolean value. That is why used the expression you had inside a nested if and set the flag which you could use later in a desired way.

sorry but can you get the idea from the automation and test with another new one i can send to you all he required data for this to see the problem.
1- i have used excel activity to read the excel file i have sent to you.
2-for each row activity to iterate throw the file.
2- i have use 4 assign activity to separate the values in the DFF column like the following

  • this for the first set of digits System.Text.RegularExpressions.Regex.Match(CurrentRow(“DFF”).ToString, “^\d+(?=.)”).Value
    -this to get the second set of digits after the dot
    System.Text.RegularExpressions.Regex.Match(CurrentRow(“DFF”).ToString, “(?<=^\d+.)\d+(?=.)”).Value
    this to get the third.
    System.Text.RegularExpressions.Regex.Match(CurrentRow(“DFF”).ToString, “(?<=^\d+.\d+.)\d+(?=.)”).Value
    -this to get the fourth.
    System.Text.RegularExpressions.Regex.Match(CurrentRow(“DFF”).ToString, “(?<=^\d+.\d+.\d+.)\d+$”).Value
    just use the data from the excel file that i will share
    GL Template.xlsx (11.3 KB)

after that use message box to make sure that each variable holds the correct value.
you will see that if the second value is null the robot will give you the third value also null even if there is data in it.

Okay sure let me work through this.

1 Like