question

Raul Vazquez avatar image
0 Likes"
Raul Vazquez asked Enrique Elizaga commented

Check if row in table does not exists for custom code

Hi team,

Im creating a logic to find values using a row name like below:


Table("WO_ConfigTable")["Dummy_"+something]["Line"]

where "something" can change due is string variable in my model , but there are cases where i dont have the proper row header name and that is ok but this issue appear below when i have a not valid row header:

exception: FlexScript exception: Dummy_Generic is not a valid row name for Global Table "WO_ConfigTable" at <no path> c: <no path> i: <no path>

Could you please let me know what i can use in order to return "0" for the null values? in order to dont have issues in the system console.

I tried using "if(Table("WO_ConfigTable")["Dummy_"+something]["Line"]==NULL)" but not work


Thx a lot

FlexSim 20.1.3
flexsim 20.1.3nullrowheaderno path
5 |100000

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

1 Answer

Phil BoBo avatar image
2 Likes"
Phil BoBo answered Enrique Elizaga commented

If your table is a treenode table, you can access its subnodes to see whether the row exists:

Table myTable = Table("GlobalTable1");
string rowName = "Dummy_Generic";
string colName = "Line";
treenode tableNode = myTable;
if (!tableNode.subnodes[rowName])
    return 0;
return myTable[rowName][colName];


1594675733040.png (37.1 KiB)
· 2
5 |100000

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

Raul Vazquez avatar image Raul Vazquez commented ·

Thanks a lot , this do exactly what i need,

0 Likes 0 ·
Enrique Elizaga avatar image Enrique Elizaga commented ·

This is awesome it was giving me a headache.

Thanks

0 Likes 0 ·