Check Excel cell value & use If activity

value is stored in a variable & Check with the excel column if the value is present or not
In my case, I have a value “56.00” stored in a variable,
I need to check whether the “56.00” value is present in the Numbers column in excel,
If it is present/Not present I need to perform other actions or log a message. How to do this with IF activity?
Book4.xlsx (9.4 KB)

1 Like

Hi,

  1. read the excel file and put into data table
  2. use for each activity use use the data table
    3.inside for each ( datatable)
    if
    row(0).tostring = variable 56.00
    then
    log " present"

else
“not present”

hope this helps

1 Like

Hi @Praveen_Vs ,

You can use a for loop and a If condition to check for the required condition
image

In the Then block put the activities for matching case and Else part use the activities for not matching case.

If values are coming in double format then you case use the below for condition :
Cdbl(CurrentRow(“Numbers”).TOString.Trim).Equals(Cdbl(YourVariable))

Regards,
Rohith

1 Like

@Ahmad_Rais @rohith.prabhu Its working, But if the Number is not found means i need to throw a business exception, So now it is iterating on the for each so every time when the Amount not match means, How to throw a Business Exception here ?
Screenshot 2022-08-12 142121
Screenshot 2022-08-12 142150

Hi @Praveen_Vs

Use Throw activity

New BusinessRuleException("Message")

image

Regards
Gokul

1 Like

Hi @Praveen_Vs ,

In else part use the Throw activity and provide the below value for it.
New BusinessRuleexception(“Value mis-match”)

Regards,
Rohith

1 Like

@rohith.prabhu @Gokul001
In the For each, It will check with the First value in the Excel, It doesn’t match means it will throw exception means, How it will check with the remaining numbers in Excel ?, Incase the value matches with the 4th or 5th row in excel.

@prave\
yes i concur

1 Like

This works, Need to use one more If outside For Each loop

DT.Asenumerable.Any(Function(r) r(“Numbers”).Tostring.equals(“56.00”))

Output : Boolean (True/False)

Then use if Activity …if True Means Next Steps …False Means Throw BE

2 Likes

Thanks, This is what I’m looking for.

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