How to search if a specific label of a specific label of a token exist?

How to search if a specific label of a specific label of a token exist?

miyeDP27D
Contributor Contributor
29 Views
4 Replies
Message 1 of 5

How to search if a specific label of a specific label of a token exist?

miyeDP27D
Contributor
Contributor

[ FlexSim 23.1.0 ]

I want to check if my label of label of the token = token.Pallet.Destination exist using objectexists(token.labels["labelName"]) but it doesnt work. What should I use instead?

Accepted solutions (1)
30 Views
4 Replies
Replies (4)
Message 2 of 5

joerg_vogel_HsH
Mentor
Mentor
0 Likes
Message 3 of 5

miyeDP27D
Contributor
Contributor

I tried this method but it didn't work. I am using it in the condition of the statistic collector to only extract the data if token.Pallet.FinalDestination exist. Is it supposed to be objectexists(data.token.labels["Pallet.FinalDestination"])? 1708515642630.png

0 Likes
Message 4 of 5

moehlmann_fe
Explorer
Explorer
Accepted solution

When checking for the labels you either do it in two steps: Check if "Pallet" exists, then check if "FinalDestination" exists.

objectexits(data.token.labels["Pallet"]) && objectexits(data.token.Pallet.labels["FinalDestination"])
data.token.Pallet? && data.token.Pallet.FinalDestination?

Or you chain multiple checks together, but this only works with class properties, as described here, so the expression becomes slightly more convoluted.

objectexists(data.token.labels["Pallet"]?.value?.labels["FinalDestination"]?.value)
0 Likes
Message 5 of 5

Jeanette_Fullmer
Community Manager
Community Manager

Hi @mm_y_2406, was Felix Möhlmann's answer helpful? If so, please click the "Accept" button at the bottom of their answer. Or if you still have questions, add a comment and we'll continue the conversation.

If we haven't heard back from you within 3 business days we'll auto-accept an answer, but you can always comment back to reopen your question.

0 Likes