question

Sara R4 avatar image
0 Likes"
Sara R4 asked Jeanette F commented

Custom Code in Pull From List

I am trying to pull values from a global list by writing custom code in the "Query / Object / Array" field in the "Pull from List" activity in Process Flow. I started with a simple query "WHERE row = 1" (row is a Label Field on my global list) in order to confirm the syntax is correct for the List.PullResult statement. See attached snapshot of code from my model. I would like for the token entering the "Pull from List" activity to pull a value from the list based on this query and move to the next activity.

I clicked the check syntax option (check mark at the bottom left of the window) and it does not produce any errors. However, when running the simulation a token enters the "pull from list" activity and does not pull a value from the list where row = 1. In fact, it does not pull any value and does not progress to the next activity. Is my List.PullResult statement in the attached snapshot incorrect for the "Pull from List - Query" application? If so, what changes should be made to the statement?

I am unable to share the model for review. Thank you. pull-from-list-query.png

FlexSim 21.0.1
pull from listflexsim 21.0.1
· 1
5 |100000

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

Jeanette F avatar image Jeanette F ♦♦ commented ·

Hi @Sara R4, was Matthew G's answer helpful? If so, please click the red "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 unaccept and comment back to reopen your question.

0 Likes 0 ·

1 Answer

·
Matthew Gillespie avatar image
0 Likes"
Matthew Gillespie answered Matthew Gillespie commented

Since you are using the Pull from List process flow activity you don't need to use the List.pull() method. All you need to do is put "WHERE row = 1" directly into the Query / Object / Array field.

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

Sara R4 avatar image Sara R4 commented ·

Thanks, Matt. I can do that for WHERE row = 1, but my goal is to eventually develop a more complex query that pulls from the list based on matching the puller token's name (which is a string) to a value (the specific field correlates to a label on the pushed token) on the list. There may be multiple items on the list with this value, so the token must also select an entry based on an assigned priority. I am new to FlexScript and SQL, so I was trying to start with a simple query to better understand how to build the logic. How would you recommend building this query?

0 Likes 0 ·
Matthew Gillespie avatar image Matthew Gillespie ♦♦ Sara R4 commented ·

@Sara R4 You can use the Query / Object / Array field to dynamically write the query you want to use, something like:

return "WHERE " + token.name + " = " + token.SearchValue + "ORDER BY Priority";

So that if you have token1 with name "row" and a SearchValue label of 4 and token2 with name "col" and a SearchValue label of 15 then you would get these queries:

WHERE row = 4 ORDER BY Priority
WHERE col = 15 ORDER BY Priority
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.