Nested multi instances result

Hi all,

I’m trying to design a process with nested multi instance process.


The process should browse the json example input, and for each user in the list, browse all le roles, and for each role wait for a message that update its status. When all the roles update messages for a user are receveid, i should wait for a message to update the user status.

example input :

[
   {
		"id":"user1",
		"state":"created",
		"roles":[{"id":"user1.role1","state":"created"}]
   },
   {
		"id":"user2",
		"state":"created",
		"roles":[{"id":"user2.role1","state":"created"}]
   },
   {
		"id":"user3",
		"state":"created",
		"roles":[{"id":"user3.role1","state":"created"},{"id":"user3.role2","state":"created"}]
   }
]

At the end of the process, I should have a list of my users with their updated status and roles.
Actually, I have two multi instance process (one to loop for users and one to loop for roles per user)

My configuration :
image

When i run the process, and i send all the messages
I’m getting this result :

[
{"id":"user1","state":"validated","roles":[{"id":"user3.role1","state":"ACTIVATED"},{"id":"user3.role2","state":"ACTIVATED"}]},
{"id":"user2","state":"validated","roles":[{"id":"user3.role1","state":"ACTIVATED"},{"id":"user3.role2","state":"ACTIVATED"}]},
{"id":"user3","state":"validated","roles":[{"id":"user3.role1","state":"ACTIVATED"},{"id":"user3.role2","state":"ACTIVATED"}]}
]

The roles collection has been overrited with the last roles collection receceived from the Browse Role multi instance.

My Excepected result is :

[
{"id":"user1","state":"validated","roles":[{"id":"user1.role1","state":"ACTIVATED"}]},
{"id":"user2","state":"validated","roles":[{"id":"user2.role1","state":"ACTIVATED"}]},
{"id":"user3","state":"validated","roles":[{"id":"user3.role1","state":"ACTIVATED"},{"id":"user3.role2","state":"ACTIVATED"}]}
]

Thanks for your help !

1 Like

Hi @m.issoulghane and welcome to the forum.
How are you assigning the variables roleUpdated and more interesting the variable userUpdated?
Are you assigning the rolesOutputCollection to the updated user?

Hello @rohwerj
Thank you :slight_smile:
The roleUpdated variable is assigned from the message received.
The userUpdated :
→ The state attribut is assigned from a message receveid
→ the roles collection is assigned from fr roles outputCollection :

{"id":user.id,
		"state":state,
		"roles":rolesOutput}

Thanks :slight_smile:

You need to wrap your inner multi instance in a subprocess like this:


Then you can define the following output mapping on that subprocess:

user:
{
  id: user.id,
  state: user.state,
  roles: rolesOutput
}

You cannot define that as an output mapping on the multi instance subprocess itself, as the variable rolesOutput can only be accessed after the multi instance subprocess is finished.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.