Looping Data Table To Perform Specific Action if Condition met

Hello Forum,
Today I’m working on a automation which objective is to upgrade a inventory depending on products criterias.

This is how it works, First it gets the items info which it will take into consideration when looping through the Inventory Data Table, info such as Product_COD, Product_Size, Product_Location , etc.

Then it reads the excel file where is the Inventory. I configured the values so the loop where is the “if Activity” gets the first row as true and performs the speified actions, The thing is that no matter what i do it never takes the “Then branch” of the i activity, which i’m testing it as if the first row o the data table “Second image” should be set to true with the condition of the if, as you can see in the local panel the variables values match the ones in the excel file “Second image”.

Please let me know what this condition isn’t matching with the variables and the rows info.
Thank you Very much.


Inventario2

Hi,

is operator compare 2 objects as not value but same instance.

Please see the following document in detail.

So, in this case, we should use = operator as the following.

CurrentRow("COD.").ToString=Product_COD

If there is a possibility CurrentRow(“COD.”) is null (Nothing), the following is better.

CurrentRow("COD.") isnot Nothing AndAlso CurrentRow("COD.").ToString=Product_COD

Regards,

Hello @Yoichi
I’ve made the research you ask and also the wrote the formula as you ask, and still i haven’t had the expected result, the if statement is unable to reach with the result “true” “then” even i all the data seems it matches the condition. Look Image below.

I don’t what am i skipping here.

Hi,

Which string do you evaluate? As there seems extra space after “Luis Fernando”, it might be better to use Trim method as the following.

CurrentRow("COD.") isnot Nothing AndAlso CurrentRow("COD.").ToString.Trim=Product_COD

or

CurrentRow("COD.") isnot Nothing AndAlso CurrentRow("COD.").ToString.Trim=Product_COD.Trim

Regards,

Would you like i send you the worklow? , Because i’ve tried that already and still haven’t gotten result. Also checked the scopes and all and stills recieve the same error.

I started to try the same logic but in a more simple worklow as you can compare on my first post and on my reply to see i its has something to be with the complexity o the first workflow. But as I said, no result yet.

HI,

Alright. Can you share your data ( and current workflow if possible)? it’s no problem if dummy data.

Regards,

I’ll send you both workflows, the simple one (DEMO) and the real one (UPGRADE INVENTORY) with the input data

DEMO.xaml (10.6 KB)
UPGRADE INVENTORY.xaml (16.2 KB)
C1.A2021 (inventario) (2).xlsx (14.6 KB)

Let me know what you see.

Hi,

DEMO.xaml need to be added Trim method to the condition as the following, because data contains whitespace.

I’ll check another one.

Regards,

Great news! Let me know what you think about the other one then.

HI,

As there is no “n/a” in your ESTADO column, it always flows to Else. Can you share your intent regarding this condition?

Regards,

What i did first with that condition was “Currentrow2(“ESTADO”).ToString = Nothing” whih i wanted to meant that i the current cell was empty. Then What i did was update that cell to “n/a” that why i used then "Currentrow2(“ESTADO”) = “n/a” ".

My main objective is that if the CurrentRow(“ESTADO”) cell is empty the set it to true.

Hi,

My main objective is that if the CurrentRow(“ESTADO”) cell is empty the set it to true.

In this case we need to use the following expression, for example.

(CurrentRow2("ESTADO") is Nothing OrElse String.IsNullOrEmpty(CurrentRow2("ESTADO").ToString))

Can you try the following xaml?

UPGRADE INVENTORY.xaml (16.2 KB)

Regards,