Skip to main content


The requirement is to provide a
feature that will allow the originator of a process to pick one or more users
from the AD and allow them to be the destination users for all of the infopath
client events.


 


I’m trying to do this with a
Smart Object that stores all the users for a given process instance
(ProcessInstanceID, Username). Using this SO I can create a dynamic role that
will be used as the Destination role for the activities. Does this sound right?


 


The point I’m stuck at is
defining a role that can have a filter for the process instance id. When
creating the role how can I say that the GetList method when executed should
have the process instance id passed in so that only the users for the specific process are resolved?


 


Any help/thoughts are greatly appreciated.


Is the following the entire requirement?


"The requirement is to provide a feature that will allow the originator of a process to pick one or more users from the AD and allow them to be the destination users for all of the infopath client events."


If this is the case, I would simply store the selected user(s) in a table, SharePoint list, etc. and then just use the results of a SmartObject GetList method as the Destination User of every Activity.  Your table structure could be very simple and just hold the Process ID and a User column that stores the ActiveDirectory ID in the domainusername format. 


Example:
1234    contosojohnd
1234    contosojaned
4321    contosomikef


In the Destination User text box, just drag the 'User' property from the SmartObject's GetList method that is pointing to that table and you're done.  If you use a SharePoint list, the 'User' column could be a 'Person or Group' field and you can use that as well in the Destination User field since the value stored in that data column is actually in the domainusername format.  Another option is to use a Contact Selector on the InfoPath form and then use that node from the XML field in the Destination User field.


There are a few ways to easily meet that requirement, but I'm not sure why you need to use Roles here.  It isn't necessary.


Thanks a lot for the detailed reply Erice. Infact this is exactly what I implemented yesterday. I created a SmartObject and used that in the destination.


But your right, I didn't mention my other requirement. If the list of users are changed I want the users to immediately see the activity in the worklist. Even if the activity has already started.


It was for this second reason that I was trying to take the Roles approach. Correct me if I'm wrong but I've come to realise that K2 does not support roles that are dynamic for each process instance. You can have a dynamic role for an entire process but you can't have the members in the role being different for each process instance (by passing the process instance id to the role).


Until I can find a better approach I've followed a tip on one of the other forum posts which is to create an action that points itself back to the same activity. Then in the UI where I let the end user pick the destination users I search for an current worklist items for the specified process instance and if it is the activity I execute that new action.


It would be elegant if there was a way to signal K2 to make the worklist item show up for the updated destination user list without having to do this redirect hack.


Cheers


Ok, that makes sense now.  I suppose you could use the SourceCode.Security.UserRoleManager.Management namespace to:


1. Create a new dynamic role for that instance
2. Add users to that role
3. Get the users in that role at each activity for the destination user(s)
4. Delete the role at the end of the process


I have never done that, but it is certainly possible.  You'll have to write some code, and you would have to test the load it puts on the K2 server based on your expected traffic.  There is some very good sample code on how to use that namespace in the K2 Documentation under the 'K2 Developer Reference -> Users -> Roles' section.  If I were to take this approach, I would probabably build a ServiceObject for at least the part that gets the users in that role (it won't be available in the Object Browser at design time).  That way I could use a SmartObject to get the users in that role at runtime so I wouldn't have to use code at each Activity in the Destination Rule.


Edit to my last response:


You don't have to build any ServiceObject to retrieve the users in a role.  The URM Service object is already available for that out of the box.  Just build a 'Roles' SmartObject that consumes one of the available methods in the URM service (ex: URM Service -> User -> Get Role Users) to get the users in that role.  Basically you would just need the API to create the role, add the users to the role, and then delete the role at the end of the process.  You shouldn't need any code for the Destination Rule if you build a SmartObject against the URM Service.


Now that's a great idea. Thanks!


Did this work? For me one have to use role as destination rule to be able to update the task list.


I tried to use the URM Service, but it does not get updated.


If you got this to work, it would be nice to know how.


Regards
Jan


No I did not use the role creation. Instead I added the user to the destination and then redirected the activity back to itself.


Reply