I want to update multiple rows in a data table based on the condition applied on columns

I want to update a data table based on certain conditions
I have a scenario where I want to put multiple conditions on different columns in where condition - and update multiple rows .I want to use invoke code activity with C#. Since ,I am a beginner I am trying the below but not able to get the desired output

DT.AsEnumerable().Where(r => r(“total amount”) <= Threshold AND r(“Status”)IS NULL)
.ToList()
.ForEach(r => {
r[“Status”] = “Completed”;
r[“Remarks”] = “XYZ”;
});

Hi @Yoichi ,

Can you please help.

Hi,

Can you try the following expression?

dt.AsEnumerable().Where(r => r.Field<double>("total amount") <= threshold && string.IsNullOrEmpty(r["Status"].ToString()))
.ToList()
.ForEach(r => {
r["Status"] = "Completed";
r["Remarks"] = "XYZ";
});

It’s assumed type of “total amount” column is double.

Sample20211013-2CSv5.zip (3.0 KB)

Regards,

Why?

This is what we call a black box - something that is difficult for others to interpret, making it more difficult in the future for your automation to be maintained and updated.

Why not just do it with activities? For Each Row on the dt, and update the values with Assign inside an If.

Hi @Yoichi ,

I am getting this error while executing the .xaml file , “Invoke code: Exception has been thrown by the target of an invocation” , there is no syntax error . Please help.

we can filter with LINQ and updating within a for each

so only the relevant rows will be edited

Hi,

Can you share $exceptionDetails in LocalsPanel when run in debug mode?

Regards,