Get value in code: Table.getRowByKey() and Table.getValueByKey()

Get value in code: Table.getRowByKey() and Table.getValueByKey()

shanice_c
Not applicable
32 Views
9 Replies
Message 1 of 10

Get value in code: Table.getRowByKey() and Table.getValueByKey()

shanice_c
Not applicable

[ FlexSim 21.1.4 ]

Hello, I need some help in reading value in code.

1. I'd like to know the time item exit the Queue and Processor, there is one field that I need some help, which is exit time from Processor and Queue. I use Trigger onExit to record the time. But the value follows item. How could I track the item just leave from Queue or Processor, and read it's label value?

1627465556403.png


2. I would use the data in GlobalTable above, and then add fields in ItemLists. I use global table lookup to refer the data, but have problem with [value.row]. I tried to use Table.getRowByKey() and Table.getValueByKey(). but can not read values from table.

1627521360815.png



3. There's an exception: FlexScript exception: MODEL:/Tools/ProcessFlow/ProcessFlow/Custom Code: Update EQ Table>variables/codeNode. What is the problem?

4. I use 3 Itemlists currently in my model, but I'd like to let AGV load item to Processor first if available, then load item to Queue secondly. Is there any way to push item from source to 2 different lists?

Thank you!

AGV write to table.fsm

0 Likes
Accepted solutions (1)
33 Views
9 Replies
Replies (9)
Message 2 of 10

Jeanette_Fullmer
Community Manager
Community Manager

Hi @Fiona C,

It's hard to know how to help without looking at your model. To receive a more accurate solution, please post your model or a sample model that demonstrates your question.

Proprietary models can be posted as a private question visible only to FlexSim U.S. support staff. You can also contact your local FlexSim distributor for phone or email help.

Could you elaborate on what you mean in bullet 1 when you say "But the value follows item. How could I track the item just leave from Queue or Processor, and read it's label value?"

For bullet 2, do you use

Table("Name of Table").getRowByKey("key", "columnName")

For bullet 3, there is an error in your "custom code: Update EQ Table". I can't help you fix that without your model.

For bullet 4, you can sort the list by destination or partition if you would like the AGV to focus on certain flow items first.

I can more easily help you if you upload your model.



0 Likes
Message 3 of 10

shanice_c
Not applicable

Hi @Jeanette F, Thanks for your reply. I'm sorry the model was not uploaded successfully yesterday, I have upload it again!

For bullet1, I used trigger to get the item exit time from Queue and Processor. Since the EQtable is specialized for saving data concerned Processor. I found the possible Processor status in my example are idle, processing, or blocked. Since item exit is not going to happen when Processor status is idle and processing. So in my custom code, I use If statement to writeto globaltable when status is blocked. But it's also unable to get exittime before item really exit the Processor.

Maybe it's a little bit meaningless to gain this data at this place. But I do this since hope can see whole Processor information dynamically.

For bullet2, I tried this but it seems some fields (EQLocation, pickupCP, EQID) still not getting the correct data.

For bullet3, please help me with fixing this error.

For bullet4, since the destination is unknown until find if there's Processor available. If there's no Processor available, destination is Queue. If there's Processor available, destination is Processor. How can I do this?

Thank you very much!

0 Likes
Message 4 of 10

Jeanette_Fullmer
Community Manager
Community Manager
Accepted solution

Hello @Fiona C,

Bullet 1: I suggest that you use the triggers on each of the objects to write to the global table instead of your custom code. I set this up on Processor1 for you.

Bullet 2: You were not using the .getRowByKey correctly. How I demonstrated above in code is how you should use it. I also used it in the list 3, so you can look there for a better example as well. Please note, the columns "pickupCP" and "EQID" still do not work because the EQLocation is written into the list like "/Processor1" and you write it into your table like "Processor1". I could not find where you write it into your table to fix this.

Bullet 3: This exception was from Process Flow in the activity called "custom code: Update EQ Table". To debug your custom code I used a break point and then went line by line through your code. The problem seemed to be coming from line 56 where you try to have "n/a" assigned to a number field. Please look at this and decide what you would like to have filled there instead. You could change the data in that field to be flexscipt.

Other Error: In your ProcessFlow_02 in the activity called custom code: Get Task, there is a character being used in line 10 that should not be there. Please review this code.

Several of your collums in your field could more easily be filled by triggers on the objects than by using your custom code. I suggest you consider changing that.

Bullet 4: This question requires better understanding of what you are trying to do with your process flow. I suggest creating a new post for this question. When you do so please give more deatails about what you are trying to accomplish overall and where in your process flow you might see your problem. I think there might be a simpler way to do this. You can tag me in the new question to help.

We are happy to help answer your questions. Please, consider making separate posts for different questions. Your questions are more likely to be answered quickly that way. Please, refer to our best practices.

agv-write-to-table_JF.fsm

0 Likes
Message 5 of 10

shanice_c
Not applicable

Hi, @Jeanette F, how could I write "/Processor1" to "Processor1"? This part is at Custom code: Update EQ Table, line 26th. Why it can only be refered if written in "/Processor1" format? What's this kind of purple font means?

1627823240163.png

I create a new post for the question pushing item to different lists. https://answers.flexsim.com/questions/105801/how-to-know-products-destination-then-push-product.html

Could you kindly help me with the problem? Thank you.


0 Likes
Message 6 of 10

Jeanette_Fullmer
Community Manager
Community Manager

Hello @Fiona C,

The purple coloring means that it is a pointer. A pointer is an address to a specific object in the model. Here is how you can change that in your table within your custom code.

1628002661442.png

0 Likes
Message 7 of 10

shanice_c
Not applicable

Hi @Jeanette F ,I had fixed the script to write into a pointer, but the "pickupCP" and "EQID" value still not show up. Then, I use triggers to set a new label "QLocation" for item, and use it to get row, like the following picture, then the QueueID value did show up in list. But could I use table information without use another new label to get row? What's the script that should be put after "value._____", should it be a label or a column name of the table?


1628147739642.png


Does the it still have to be in purple font in the list when written to list or simply Processor name with a slash is correct?

agv write to table_0805.fsm

0 Likes
Message 8 of 10

Jeanette_Fullmer
Community Manager
Community Manager

Hello @Fiona C,

I think you have a typo. For the pickupCp expression you use "QueueLocation" (you have it highlighted) when you have it written above and below as "QLocation". I think that is the problem.

To avoid using the whole expression that gets the row number you could create another expression field and call it row to then reference in other expressions as value.row .

For some reason your list3 will not reference the epression for EQLocation. I filled in value.up instead and that seemed to work just fine.

1628278092470.png

agv-write-to-table-0805_JF.fsm

0 Likes
Message 9 of 10

shanice_c
Not applicable

@Jeanette F. Thank you for your patience. May I ask the use of "value.up"? I check that "up" means to reference a node's parent node. Gets and sets the node "above" the node in the tree, or in other words, its parent node.

But I cannot find description of "value". My problem is how does it recognize which item in list by simply use "value"? I think I need to know which item it is first, then I could know the node above it.

0 Likes
Message 10 of 10

Jeanette_Fullmer
Community Manager
Community Manager
Hello @Fiona C,

Yes, for the value.up .

The value is what ever has been pushed to the list. In this case, it is a flow item.

0 Likes