question

Anggoro P avatar image
0 Likes"
Anggoro P asked Anggoro P commented

Aggregating value based on another atribute value

Hi, I want to aggregate the quantity from table left based on the picking time, then copy the aggregate quantity into table right. For instance, it should be quantity = 8 for time = 20 and put it on corresponding row on table right (table attached)

I used this code on reset trigger, but it doesn't works. It said that there is an invalid condition type on my IF CONDITION. Somebody help me please. Thanks

/**Custom Code*/
Table current = param(1); //Table node
Array Quantity = Array(44);

int k = 0;
for (int i = -15; i <= 28; i++)
{
    k += 1;
    Quantity[k] = 0;
    for (int j = 1; j <= Table("ScheduledPicking_CO").numRows; j++)
    {
        if (Table("ScheduledPicking_CO")[j][1] = i)
        {
            Quantity[k] += Table("ScheduledPicking_CO")[j]["Quantity"];
        }
    } 
}

for (int l = 1; l <= Table("PickingReady_CO").numRows; l++)
{
    settablenum("PickingReady_CO",l,2,Quantity[l]);
}
Choose One
flexscriptflexscript error
a.jpg (58.2 KiB)
· 3
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Anggoro P avatar image Anggoro P commented ·
0 Likes 0 ·
Joerg Vogel avatar image Joerg Vogel commented ·

And I am not sure if you can already parse a string as a table column to get a table cell value. Please test this in the script console. A Flex script parameter behaves different to a string clause from SQL. In a query you can look for a column head string.

["Quantity"] vs. [2]
0 Likes 0 ·
Joerg Vogel avatar image Joerg Vogel commented ·

If you get an error you see the line number and get a description. Please add this description and attach a picture of the code editor where we can see the line number of the code. Thanks.

0 Likes 0 ·

1 Answer

Joerg Vogel avatar image
1 Like"
Joerg Vogel answered Anggoro P commented

A comparison is done by " == ". You use the assign operation " = ".

· 1
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Anggoro P avatar image Anggoro P commented ·

Thanks @Jörg Vogel! it works :)

0 Likes 0 ·