question

Philip Diem avatar image
0 Likes"
Philip Diem asked Philip Diem commented

How to query Lists for entries by fields from Label

Hi, I try to pull entries from a partition of a list.
The query i want to use should match match a value from a label on the pulling token to a field from the list.
Just like this:

WHERE MyLabel == token.MyLabel

In the model attached I tried to do it with the logic bricks. I know that doesn't work as the assign label brick uses variant instead of string datatype.
But it shows what I try to do.

If i custom code it to make sure its a string value, it doesn't throw an error but just acts like there was no match in the list - which is not the case.

If i hardcode the query to:

WHERE MyLabel == "Direkt"

It works perfectly. But as soon as I try to use a label it just breaks.
I dug through all the questions here with similar topics, but i couldn't find an answer.

What am I doing wrong?List query.fsm

FlexSim 20.1.0
labelslistflexsim 20.1.0queryfield
list-query.fsm (50.1 KiB)
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

Mischa Spelt avatar image
3 Likes"
Mischa Spelt answered Philip Diem commented

When you're using the Pull from List activity in Process Flow, you cannot use token directly in the query.

Instead, you can reference an intermediary object called the puller. By default, the puller is equal to the token that is performing the query, so you can just replace

WHERE MyLabel == token.MyLabel

by

WHERE MyLabel == puller.MyLabel

and your model should work.

That solves your problem, you can continue reading for just a bit more background about puller vs. token.

If you look two fields below the query, you'll see that in this query, puller refers to token. Why this split? I think this is one of the main reasons:

Push To List and Pull to List are made to work together. When a token enters a Pull or Push, it will (usually) sit there until a matching token enters a Push or Pull, respectively. In principle, these activities sit in different flows that don't communicate with each other, but you can pass a bit of information. For example: when the pull succeeds, the pulling token doesn't just create a label with a reference to the pulled value -- the pushing token, that gets released from the Push To List activity at that point, is assigned a label referencing the pulling token.

So in your model, in the PF on the right you will get token.pulled referencing the token on the left; and in the PF on the left you will get token.puller referencing the token on the right. Typically, in an application of orders and operators, for example, this allows you to know on the operator side which order was assigned, but also on the order side which order picker operator pulled it.

Sometimes, when you pull from a list, you may not want yourself to be set as the puller on the value that you pull. By changing the puller in your pull query, you can pass more useful information in some circumstances: for example, instead of "the token with id: 5" you can make the puller equal to an operator or rack in 3D, or if you have a child token in a subflow to do the pull action, you can set the puller equal to a parent token to preserve the information after the subflow ends.

· 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.

Philip Diem avatar image Philip Diem commented ·

Hi Mischa
Thanks a lot!

I even knew what you stated in your explanation, but I would just have never guessed that the reference does not work like everywhere else in the software ^^.

Thanks again, I would never have guessed that as I thought in this case puller / token would be interchangable.

In cases like this i would be more than thankful if I could just click on the code icon to examine what the generated code looks like. In that case it would have been completely obvious that the reference is build using the puller variable.
Maybe in one of the next versions?

Thanks again.
Phil

0 Likes 0 ·