When binding a replicator from within another replicator, you will discover the following behaviour:
We have 2 replicators:
ParentReplicator & ChildReplicator
We have 4 roles:
role1,role2,role3 and role4
We have 5 users:
user1,user2,user3,user4 and user 5
each user is connected to a role in a dictionnary
role1 has 2 users: user1 & user 2
role2 has 1 user: user 3
role3 has 1 user: user 4
role4 has 1 user: user 5
We want to iterate through each role and create a task for each user in this role.
through the designer we bind the initialchilddata property to List
using code we capture the ParentReplicator_ChildIntialized
event and execute this code:
The result is this:
Role 1
Role 2
- user 1
- user 3
Role 3
- user 2
…
SO it seems like the ChildData is only set the next iteration?…
The reason for this behaviour is because we are settings the InitialChildData on the wrong object, the object we are using is living in another context.
Use:
//use the control in this context ReplicatorActivity rep = e.Activity.GetActivityByName(PanretReplicator.Name, true) as ReplicatorActivity; rep.InitialChildData = users.Select(u => u.Sid).ToList();
here we go!
Conclusion: ALWAYS use the sender or e.Activity to get your childactivities to avoid these unhappy behaviour…
read more:
Pro WF: Windows Worklfow Foundation Pages
Very nice post that pushed me in the right direction
Good luck;)
