question

Manus K avatar image
0 Likes"
Manus K asked Sebastián Cañas commented

Referencing objects in group in subflow

I have a token with a label 'Group' referencing a specific group e.g. "Group1". Now I want to execute a subflow in which I create a token for each object within the group. Each of those tokens should carry a label 'Object' with a reference to a object in the group.

1. If I use token.Group.subnodes.length as Quantity in the Create Tokens activity I get a token for each object but one additional parent token for which I don't have any use. Is there a way not to carry the parent token through the subflow?

2. Object label

2.1 In another project I used Group("Group1")[x] but token.Group[x] does not seem to work. What's the right way to reference?

2.2 How do I defined the index 'x' in the correct way? In the other project I used [tokenIndex] but this seems to be a global index and not a 1,2,3,.. for each new set of tokens in the subflow.

FlexSim 23.2.3
process flowlabelssubflowgroups
· 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.

Sebastián Cañas avatar image Sebastián Cañas commented ·
@Manus K ,

Could you please upload your model or a demo of the logic you built?

0 Likes 0 ·
Manus K avatar image Manus K Sebastián Cañas commented ·
0 Likes 0 ·
mtbfmttr-2.fsm (40.1 KiB)

1 Answer

Sebastián Cañas avatar image
1 Like"
Sebastián Cañas answered Sebastián Cañas commented

Hi @Manus K ,
Assuming you have the reference for the group in a label Group, you could set the Run Sub Flow as the image below:

Perhaps you missed the expression creationRank that returns a numeric value. Here there is a short explanation:

When the [creationRank] part of the expression is evaluated for the first created child token, the creationRank will have a value of 1. When it is evaluated for the second created child token, creationRank will have a value of 2, and so forth.

· 4
5 |100000

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

Manus K avatar image Manus K commented ·

Thanks, Sebastian.

For the quantity I'm using token.Group.subnodes.length which seems to work.

The creationRank sounds super useful but I am unable to access the object with token.Group[x] even if I used token.Group[1] for testing purposes. token.Group.subnodes[x] also doesn't work.

0 Likes 0 ·
Sebastián Cañas avatar image Sebastián Cañas Manus K commented ·

@Manus K ,

First, you have an exception because you where using a bad reference in the Delay activities. You were using tokenIndex to reference the row of a Global Table. I created a label called Index in the source, so that you can use token.Index in the delay to reference the row.

Then, I am not sure why the expression I showed you before wasn't working, but I managed to make it worked downcasting the expression to Group as you see here:

Hope this helps! Sorry I cannot send a model back, but I do not have the version you use, hope the screenshots are enough

0 Likes 0 ·
Manus K avatar image Manus K commented ·

Thank you! That's working just fine!

What's the reason behind tokenIndex not working? Does that only work directly in activities?

0 Likes 0 ·
Sebastián Cañas avatar image Sebastián Cañas Manus K commented ·
@Manus K ,

As far as I know tokenIndex is an expression that only works in Schedule Source and from 23.2 or 24.0 (don't remember well) in Date-Time Source as well. If you try to use it in any other Process Flow activity it won't work.

1 Like 1 ·