How to check column value

Hi,

I need to send mail if column ‘c’ contains ‘success’, if I use for each row, the mail is getting triggered as many times success is present. I need to send single mail if any of the cell contains ‘success’ on column ‘c’

1 Like

Hello @Priya_Sri,

DataTable.Rows(2)(“columnname”).ToString = “success”

Try this

Should this be used inside a for each row?

1 Like

Not required!
use Read Range and If condition and pass this syntax!

Cheers

Hi,

Can you try the following condition in If activity?

dt.AsEnumerable.Any(function(r) r("NameOfColumnC").toString.Contains("success"))

img20200723-1

In this case, you don’t need to use for each row.
dt is output of Read Range activity and please change the column name to yours.

Regards,

It worked! Can I add and or condition with this (i.e., to add condition if it contains ‘error’ values also in column ‘c’ )

1 Like

Yes. Hope the following helps you.

Check if it contains “success” or “error”.

dt.AsEnumerable.Any(function(r) r("NameOfColumnC").toString.Contains("success") OrElse r("NameOfColumnC").toString.Contains("error") )

In some condition, you can also use Regex.IsMatch method as the following.

dt.AsEnumerable.Any(function(r) System.Text.RegularExpressions.Regex.IsMatch( r("NameOfColumnC").toString,"success|error" ))

Regards,

1 Like

how can I check an empty cell value instead of error

dt.AsEnumerable.Any(function(r) r(“NameOfColumnC”).toString.Contains(“success”) OrElse r(“NameOfColumnC”).toString.Contains(“error”) )

1 Like

Hi,

how can I check an empty cell value instead of error

The following helps you.

dt.AsEnumerable.Any(function(r) r("NameOfColumnC").toString.Contains("success") OrElse String.IsNullOrEmpty(r("NameOfColumnC").toString))

If you have null reference error, you need to check if r(“NameOfColumnC”) is null as the following

dt.AsEnumerable.Any(function(r) r("NameOfColumnC") is Nothing OrElse r("NameOfColumnC").toString.Contains("success") OrElse String.IsNullOrEmpty(r("NameOfColumnC").toString))

Regards,

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