How to use multiInstanceIterator?

I am now working on Community 7.2.3…

Here is my requirement:

  1. When process starts, Imitator can select x people from Instantiate form (x = 1…n) as next step’s approve.
  2. When there’s > 50% of x people approve at step 2, then step 2 is considered as approved and move to end
  3. When all people in step 2 completes the task, but < 50% people approve, then step 2 is considered as rejected and move to end.

I am trying to use Parallel multi-instantiation to implement this requirement. What I have done so far is:

  1. Define a pool level process variable call listOfApprovers with List type
  2. listOfApprovers will keep selected approver’s user name post Instantiate form submit
  3. In next Human Task step, under Iteration pane, I indicate Paralle multi-instantiation, check on Create instances from a list, give listOfApprovers as Input list.
    4)Created a Actor Filter, trying to get user id with the value in multiInstanceIterator

However, I got nothing from multiInstanceIterator. I searched around in this forum, there’s no answer on this kind of usage.

But funny thing here is multiInstanceIterator do have value of user name if I display it in the form of Human Task, when I retrieve this data with external API …/API/bpm/activityVariable/{{taskId}}/multiInstanceIterator

So does this multiInstanceIterator only be set with value post task is created or assigned? What would be recommended solution to implement my requirement?

The way we did it was use get the id of the user we want to assign to and assign direct, no need for any actor filter.

pid = start process
wait for process to start
assign userid to pid.

works fantastically.

the thing is, is not to assign any actor to the authorization process (in studio design) but only assign via code.

I can’t give you the code we’ve developed but I can give you this:

Select Users (form)
get Users ID save into List (service script connector)
multiInstantiate on each user call sendApproval

sendApproval (sub process, id)
pid = startprocess()
timer to wait for process to start up
assign user id to pid

All done

regards
Seán

Thanks Sean. Could you please elaborate a bit more on your approach? I am not getting the point of how to get user id for each iteration.

The work around I am using now is adding a pooled variable which represents loop index, using this in Actor Filter so can get user id / name from list, and +1 onto this pooled variable after each iteration.

Correcting one thing:

we start a NEW process, we do not have the different tasks in the same process, you require your multiInstanTask in the same process so this task should be a Human Task

the following is based on your requirement.

Our process starts with a Select List (checkbox) of names we can use for the next step.

So our form has, for example

person 1 yes/no person 2 yes/no person 3 yes/no . Person 30 yes/no

say we select person 10, 15 and 30, well we know who they are so in the Output operation we interrogate the Organization and get their ids, and add them to a List. (listOfSelectedpersons)

We then multiinstantiate against listOfSelected with variable selectedPerson.

selectedPerson is the id that you want to use in your filter to assign the task to the next person.

Does that help?

regards

I was doing the same thing, only the variable name was different. I was using its default name call “multiInstanceIterator” while yours is “selectedPerson”.

According to your approach, you create new processes from root process, and set its assignee from root process, where “selectedPerson” definitely has a value to refer to.

In my approach, I was trying to refer to “selectedPerson” as an activity variable in Actor Filter. Also activity variable uses the variable’s name which is defined in multiinstantiate, they are two different variables. Therefore the timing to access this activity variable makes a lot difference.

As per my findings, i guess activity variable only be set with values post the task is assigned to some actors. Therefore it cannot get activity variable in Actor Filter, and my approach won’t work. I will do one more test with local variable to double confirm on my guess.

I just did a test with local variable which has a default value…

In Actor Filter, I use accessor.getProcessAPI().getActivityDataInstances to list down all activity data. Local variables are not there, however pool variables are there.

Is this inconsistent behavior? If it can access pool variables in Actor Filter, local variables should also be accessible.

I know what you mean, though Bonitasoft will probably disagree, just use a pool variable :slight_smile:

regards
Seán