I have been attempting a user event that essentially checks a global list of items that is continuously updated. This list of items is then transfered into variables and converted using multipliers so that I can better understand inventory in the form of pallets over time.
The event code is as follows
/**Custom Code*/
Object current = ownerobject(c);
double ItemPallets;
double Total_Pallets = 0;
int Pallet_Item = 1;
double NumRows = Table("WarehouseInv").numRows;
while (Pallet_Item <= NumRows) {
string strItemVal = "SELECT Quantity FROM GlobalWarehouseInv WHERE MatlName = Item " + numtostring(Pallet_Item);
string strItemTemp = "SELECT Temp FROM GlobalWarehouseInv WHERE MatlName = Item " + numtostring(Pallet_Item);
string strItemSize = "SELECT Size FROM GlobalWarehouseInv WHERE MatlName = Item " + numtostring(Pallet_Item);
//query returns a Table. Here we expect a single value in the table.
Table I = Table.query(strItemVal);
Table T = Table.query(strItemTemp);
Table S = Table.query(strItemSize);
double NumItem = I[1][1];
double ItemTemp = T[1][1];
string Size = S[1][1];
if (Size == "S")
{ItemPallets = NumItem*0.2;}
else if (Size == "M")
{ItemPallets = NumItem*0.4;}
else
{ItemPallets = NumItem*0.6;}
Total_Pallets = Total_Pallets + ItemPallets;
Pallet_Item = Pallet_Item + 1;
}
I keep recieving the following error however: time: 5.000000 exception: FlexScript exception: Invalid row number: 1 in Table.query() result table. at MODEL:/Tools/UserEvents/CalcPallets>variables/event