question

Aditya Prakash avatar image
2 Likes"
Aditya Prakash asked Jordan Johnson answered

Search a field value in list entries

OnMsg trigger I need to search through all values (Entries as well as backorders) in a global list, checking for a field value. How should I do it ? Is there a command for that or should I create a duplicate table and keep updating it at each PUSH/PULL, and query from this table.

FlexSim 16.0.1
list entrieslistbackorders
· 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.

Aditya Prakash avatar image Aditya Prakash commented ·

One way I found is query("SELECT * FROM List_name WHERE field = var "). This throws count of occurrences where I meet my criteria. Is there any other way ?

0 Likes 0 ·
Mischa Spelt avatar image Mischa Spelt commented ·

I think it is the most efficient way. Does it not give you the correct result? Maybe you can do something with partitions, but I haven't used those yet so I'm not sure how to get the content of a partition.

0 Likes 0 ·

1 Answer

·
Jordan Johnson avatar image
4 Likes"
Jordan Johnson answered

You can search the entries on a list using the listpull command. This command will return an array of items that match the query. If the request number and require number are zero, then the items will not be removed from the list:

listpull("GlobalList1", "WHERE fieldName = someValue", 0) 

You don't need SELECT or FROM statements in this query, and you can use field names directly. The result will be an array of values. The type of the array will depend on the type of values that are on the list.

It doesn't make sense to search back orders for field values. Field values are assigned when an item is pushed on the list. Back orders are created when you use the listpull command, with a require number greater than zero, but items matching the pull query do not exist on the list.

5 |100000

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

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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