Friday, June 5, 2015

How to assign a Team or User to an activity dynamically in IBM BPM

From IBM BPM v8.5, the Assignment options which were there before such as "Last User in the lane", "Routing Policy",  "List Of Users" and "Custom" were deprecated an can no longer be used for the Task Assignments. In older version the option "Custom" was being used for dynamic assignment of Team or User to a Task. In the latest versions of IBM BPM i.e., from V 8.5.0 a new way of assignment has been introduced i.e., using the "Team Filter Service".

In this post, let us look at a code sample illustrating the Dynamic task assignment for user using Team Filter Service.

As a first step create a simple BPD with one Activity with a Human Service. Click on the activity and navigate to Properties --> Assignments and click on new in-front of  "Team Filter Service" to create a new Integration service (team filter service) as shown in below figure or select an already created service.




Now in the "Team Filter Service", navigate to "Variables" section and create a new variable called "toUserId" as shown in the figure. This variable can be used to pass the userId to be assigned.


Let us look at the Assignment Tab of the activity in bpd after attaching the "Team Filter Service". Below figure shows the view of Assignment Tab for the activity along with the input mapping.



Now let us look at the script which is used to create a Team with the users passed dynamically to the Team Filter Service. In this Script we need to create the Team of User and assign it output Variable "filteredTeam". Below figure shows the diagram of the "Team Filter Service".


Below is the script using which the Team is created with the users passed dynamically.

tw.local.filteredTeam=new tw.object.Team();
tw.local.filteredTeam.members=new tw.object.listOf.String();
tw.local.filteredTeam.members.insertIntoList(tw.local.filteredTeam.members.listLength, tw.local.toUserId);

Once the BPD is Created and assignment is done as explained above. Create an instance for the BPD, you will notice that the task is assigned to the team created with list of Users.

This script can be extended to filter the users from the given team based on certain parameters or to create new temporary temporary team with of the list of intended users or any other scenario where the intended Users / Teams are determined dynamically during run time.

Hope this is use full !!!

Thanks for stopping by. If you like this post leave a comment, share it and do a g +1.



3 comments:

  1. Hi Pradeep,

    I have requirement, where user will enter the project manager name in UI, and approval process activity will assign to that project manager name, I have tried your logic, but not able to implement.

    So every time, we run the process, activity should assign to only one person, ie Entered project Manager

    Could you please help.

    ReplyDelete
    Replies
    1. hi Pradeep, i have the similar requirement.Have you got any solution?

      Delete