question

Kashif A avatar image
0 Likes"
Kashif A asked Matthew Gillespie commented

Custom code query in pull from list activity of process flow.

I have a pull from list activity where I want to apply a custom code query in the query field. The query I want is as follows:

There are two expression fields on the list entries. First one is "flag" and the second one is "utilization". I only want to pull those entries whose utilization is less than 95. But I want to do this check for only those entries whose flag is equal to zero. For all other entries whose flag is non-zero, I don't care about its utilization, I will simply pull it no matter what the utilization.

What should I write in query field to achieve this?

Also, is there an Onpull trigger inside the pull activity that I can use to update some global table values when a pull occurs?

pulling from lists
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

Use the query

WHERE flag OR utilization < 95
There’s no OnPull trigger, but the token will move on to the next activity as soon as it finishes the pull. So you can just put a custom code activity right after.
· 3
5 |100000

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

Kashif A avatar image Kashif A commented ·

Wouldn't this query cause both entries with flag=1 and flag=0 to be evaluated instead of entries with just flag=0 because both 1 and 0 are less than 95? For example, if there is an entry in the list with flag=0 and utilization=96, it would get pulled because 0<95 and whe have an "OR" operator. But it should not be pulled.

To the second point, the reason why I need an Onpull trigger inside the pull activity itself is because there I are multiple entries being pulled by a token and I want to update some global table value corresponding to each of these pulls as they happen.

(One more trivial question here. Should it be written Puller.label or puller.label inside query?)

0 Likes 0 ·
Kashif A avatar image Kashif A Kashif A commented ·

I think this should work:
WHERE (utilization<95 and flag==0) OR flag==1

0 Likes 0 ·
Matthew Gillespie avatar image Matthew Gillespie ♦♦ Kashif A commented ·

No, that's not how boolean expressions work. If you wanted either flag or utilization to be less then 95 you have to write that more explicitly, like this:

WHERE flag < 95 OR utilization < 95

That other query would definitely work, but it's not necessary to write it out that verbosely.

Take a look at the query I suggested again

WHERE flag OR utilization < 95

What this is saying is that if "flag" is true (0 is false and anything else is true) then the whole WHERE statement is true regardless of the utilization. On the other hand, if the "utilization" is less than 95 then the whole statement is true regardless of the value of "flag". The only time this statement if false is if "flag" is 0 and "utilization" is 95 or more.

Like I said, there's no OnPull trigger. However, the List does have an OnValuePulled event that you can listen to. Here's an example model. onvaluepulled.fsm

Puller can be either upper or lower case, but we recommend doing upper case just so it's clearer what you're doing. See the user manual page here, https://docs.flexsim.com/en/20.0/Reference/Tools/GlobalLists/FunctionalReference/#QuerySyntax

0 Likes 0 ·
onvaluepulled.fsm (29.2 KiB)

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.