question

Kamil KS avatar image
0 Likes"
Kamil KS asked Matthew Gillespie commented

How to change the code in PF List properties ?

Hello,

How can I change the code in List Properites -> Fields to get logic like below?

1. I want to have the Expresion Field showing the distance between the puller and the FlowItem Destination label. Not as in the standard option between the resource and the puller.

2. I want to have the Expresion Field showing the subnodes length of the FlowItem Destination label also. I tried with that code but apparently it's not working properly.

I am familiar with using Flexscript but I think I am missing the libraries code logic in the begining of the code. testmodelwms.fsm

FlexSim 18.2.3
process flow
code.png (13.0 KiB)
testmodelwms.fsm (81.8 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

Matthew Gillespie avatar image
1 Like"
Matthew Gillespie answered Matthew Gillespie commented

You're not using the correct header. You seem to have copied the header from an Assign Labels activity. The code snippet in your picture should look like this:

/**Custom Code*/
Variant value = param(1);
Variant puller = param(2);
treenode entry = param(3);
double pushTime = param(4);

Object paleta = value;
string bl = paleta.Destination;
Object bin = Model.find(bl);
return bin.subnodes.length;

Since you're pushing token.FlowItem on the list that is the value.

I've updated the Capacity-notworking and distance fields in this model. listfields.fsm


listfields.fsm (81.6 KiB)
· 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.

Kamil KS avatar image Kamil KS commented ·

Thank you for your help,

Do you know how to refer to the Expresion Field value? I tried this code but it is not working:

Variant value = param(1);
Variant puller = param(2);
treenode entry = param(3);
double pushTime = param(4);


Object paleta = value;
int czas = paleta.age;
return czas;
0 Likes 0 ·
Matthew Gillespie avatar image Matthew Gillespie ♦♦ Kamil KS commented ·

You can't really have one expression field reference the value of another expression field. In your case where you need the value from the age field you should just do the same calculation that the age field does:

Variant value = param(1);
Variant puller = param(2);
treenode entry = param(3);
double pushTime = param(4);

int czas = time() - pushTime;
return czas;
0 Likes 0 ·
Kamil KS avatar image Kamil KS Matthew Gillespie ♦♦ commented ·

What if I want to count the number of items with the same ID in the list ? Do I need to export the table to the global table and there do the loop ? Is there the posibility to do it with SQL somehow ?

0 Likes 0 ·
Show more comments