Can I check datatable outputs for a particular value using an IF statement?

Hi,

I need to somehow check DT row value results for a particular variable value. If the value is found then populate a field. If the value is not in the DT then to throw an error. Is this possible please?

Thanks
T

Hi, @TRX

You can achieve this using the .Any method like this

dt_Invoices.AsEnumerable.Any(Function(x) x("NF").ToString.Trim = "131212312312312")

You can use any column to search for specifc value and compare. If at least one is found, the expression returns True

To throw a error, you can use Throw Activity and use this expression as example

new BusinessRuleException("Invoice not found")

As best practice you need to throw a Business Exception because System Exception is related to system fails etc

Solution

ExampleQueryDT.zip (2.8 KB)

HI @TRX ,
Similar topic

regards,

Thanks! This did the trick!

Thank you @Nguyen_Van_Luong1

1 Like

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