K2 Roles are similar to groups in Active Directory which are maintained with in K2 Server. These K2 Roles can be used in workflow for assigning tasks. These K2 Roles can be maintained by administrators for enrolling new users or removing the existing users.
K2 Roles can be added with a User or Group from the default security provider (generally Active Directory)
Now let’s see how to create a role and add users or groups or both to it.
1: Creating K2 Role
Step 1: Open K2 Workspace and navigate to Management Console tab and then right click on Roles and select Add New Role
Step 2: It will open below screen.
Now enter Role Name & Description and Click Add Role Item which will open another pop up where you can search Users and then select them to add it to Role.
To search user you just need to type the user name in the box provided and then click enter or click search button upon which you would see the users matched with string that you provided in search box. Now select the user that you want to add in role and then click OK.
Same way you can also search for a group to add it in role.
Also you have an option to use SmartObject to fetch the users for role by using the SmartObjects tab which right beside Users Tab in above screen. You just have to select the SmartObject then the SmartObject Method and then the Field which gives you the user.
There is a checkbox with name Dynamic about which I’m going to explain it in latter part of this post.
Now click on Save Button to save the role.
2: Using K2 Role in Workflow Client Event
Now in workflow client event we have 2 ways Simple mode & Advanced Mode
In destination user’s field just drag and drop the Role you have created from Context Browser/User Browser/Roles and click finish.
Run the client event wizard in advanced mode (Just open the Destination Users wizard click back button and select advanced checkbox to run in it in advanced mode), Now select Plan per destination – All at once and click Next button
Now in next screen select Specify the number of the slots to be created and enter 1 and below check Resolve all roles and groups to users (by selecting this option K2 will resolve the role into individual users and the task will be created for each user)
Also below there is a checkbox saying Keep roles synchronized if you check this, K2 will automatically synchronize the role when users are added and or removed while assigning the tasks
Now just click next you will see Destination Sets Wizard where you see Default. Now click edit and add the role from context browser as shown below and click finish.
Now just deploy and run the workflow to see the tasks getting assigned to users from role.
Now let’s see what dynamic K2 Roles are
Basically in K2, Once a workflow instance is created and task is assigned to some destination users then in case if you want to add a new user as a destination user or to remove user from the destination users of the task that is already created, then it is not possible unless we redirect them manually.
Now to mitigate this situation K2 have introduced K2 Roles with dynamic option. So when we say a K2 role is dynamic then it will create only one task with the role name so that while performing the action then the K2 will dynamically check whether the user performing the action belong to the respective role or not. So now it doesn’t matter how many users are being getting added/removed from role until the Task Action is being performed.
So we just need to check the check box with name Dynamic while creating a role to make it dynamic. By Default the interval for a role refresh is set to 10 minutes. If you want to modify the interval then in WorkSpace / Management Console/ Workflow Server/ Process you will see Roles, click it and add the role that you are using in the client event and then set the refresh interval and save.
That’s it. This is how we can make use of K2 Roles in our workflows.
Below are some of the links that would give more information on using K2 roles in workflows.