question

Talia Z avatar image
1 Like"
Talia Z asked Talia Z commented

Route items based on whether or not a label exists

Hello! I am hoping to route items using decision points based on whether or not a label exists. I have created this model as an example - my aim is to route the box objects to Queue1 if they have the label 'destination' and to Queue2 if this label does not exist on the object. Thank you in advance.

FlexSim_route_based_on_label.fsm

FlexSim 20.0.10
decision pointsflexsim 20.0.10route
5 |100000

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

Joerg Vogel avatar image
1 Like"
Joerg Vogel answered Talia Z commented
objectexists(object.attrs.labels.subnodes[“labelname”])
· 5
5 |100000

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

Talia Z avatar image Talia Z commented ·

Thanks for your response, @Jörg Vogel! When I add this to my Send Item condition I receive the following error message:

Flexscript Error MODEL:/DP1>variables/localType/onContinue invalid character <â> ascii = -30

Flexscript Error MODEL:/DP1>variables/localType/onContinue invalid character <€> ascii = -128

Flexscript Error MODEL:/DP1>variables/localType/onContinue invalid character <œ> ascii = -100

Flexscript Error MODEL:/DP1>variables/localType/onContinue invalid character <â> ascii = -30

Flexscript Error MODEL:/DP1>variables/localType/onContinue invalid character <€> ascii = -128

Flexscript Error MODEL:/DP1>variables/localType/onContinue

Could not finish parsing because of previous errors.

0 Likes 0 ·
Joerg Vogel avatar image Joerg Vogel Talia Z commented ·

Did you copy the source code from the internet page or did you write it yourself?

0 Likes 0 ·
Talia Z avatar image Talia Z Joerg Vogel commented ·

Yes, good point! After writing it myself I receive different errors:

Flexscript Error MODEL:/DP1>variables/localType/onArrival Line 8 Undefined variable object being used.

Flexscript Error MODEL:/DP1>variables/localType/onArrival Line 8 Data type void does not support property attrs

Flexscript Error MODEL:/DP1>variables/localType/onArrival Line 8 Data type void does not support property labels

Flexscript Error MODEL:/DP1>variables/localType/onArrival Line 8 Data type void does not support property subnodes

Flexscript Error MODEL:/DP1>variables/localType/onArrival Line 8 Invalid type for [] operation. Should be int. Left side type is (invalid), right type is char*

Flexscript Error MODEL:/DP1>variables/localType/onArrival Line 8 Invalid type for parameter 1 in call to command objectexists. Expecting treenode. Type is (invalid)

0 Likes 0 ·
Show more comments
Jon Abbott avatar image
1 Like"
Jon Abbott answered Talia Z commented

Great question! This can be accomplished using the assert method on the item destination label in decision point DP1's On Arrival trigger. This will attempt to retrieve the label value if it exists, and if it does not, it will create the label and set its value. Please take a look at the attached model and see if it meets your needs.

flexsim-route-based-on-label-ja.fsm


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

Jon Abbott avatar image Jon Abbott commented ·

If you prefer not to create a label if it does not exist, here is an example model that uses Jörg's objectexists example code in the decision point DP1's On Arrival trigger instead.

flexsim-route-based-on-label-ja2.fsm

0 Likes 0 ·
Talia Z avatar image Talia Z commented ·

Thank you for providing this alternative method! Both techniques work well.

0 Likes 0 ·

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.