AnsweredAssumed Answered

Multi Instance Set Variable On Item In Current Loop

Question asked by jamie.dulude@gmail.com on Feb 24, 2016
Latest reply on Feb 25, 2016 by jamie.dulude@gmail.com
Hello All,
I'm looking for a little assistance when using multi instance processes.

Here's my scenario…
The goal of my workflow is to essentially take a list of people and filter that list down based on a series of conditions. So for example, I might start with a list of 100 people and have a result of 5 people that passed all criteria. I'm open to suggestions on how to achieve this. My first instinct was, crap, I'm going to have to start 100 separate instances, one for each person. Then I discovered the multi instance support which is fantastic. So I got to work and build a small little POC and hit a blocker.

Here is a screenshot of the basic POC I created…
https://dl.dropboxusercontent.com/u/33369/Screen%20Shot%202016-02-24%20at%204.32.05%20PM.png

As you can see it's very simple. It can go one of two directions, either the "Keep On List" route or the "Remove From List" (my real work scenario is much more complex).

My problem is, how do I keep track of the items that should be removed?

Here is an example of the json payload I'm setting to start the instance.
<javascript>
{
   "processDefinitionKey":"LoopTest",
   "businessKey":"",
   "tenantId": "",
   "variables": [
      {
        "name": "people",
        "value": [
            {
                "flow": "keep",
                "name": "Person 1"
            },
            {
                "flow": "remove",
                "name": "Person 2"
            },
            {
                "flow": "keep",
                "name": "Person 3"
            }
        ]
      }
   ]
}
</javascript>

My sub process loops over the "people" collection and assigns the element variable to "person". The decision point checks for either ${person.flow == 'keep'} or ${person.flow == 'remove'}.

My hope was that I could use some type of executioner listener to set a variable on the actually person that is in the current loop to indicate whether or not the person should be removed or not, but I can't seem to set variables on the actual person that I'm looping over.

Any advice for me would be greatly appreciated.

Outcomes