Occasionally, you need to reassign K2 blackpearl tasks that is currently directed to one user to another.
This scenario may occur for several reasons. The user might have been moved to a new user account, the user might have left the company, etc.
If you have access to the K2 workspace you can do it quite easily by using the buttons indicated in the below screenshot. We will show how to accomplish this task programmatically.
K2 Automated Testing Software
BenchQA allows full test automation of K2, including fully automated K2 SmartForms and K2 Workflow testing. It promotes test driven development for K2 and ensures continued quality assurance for K2 solutions. Easily apply changes to test cases to accommodate changes to K2 apps and ensure all apps are regression tested to avoid defects and assure continuous quality.
Once you have referenced the K2 management API libraries, the first step will be to create a connection to the K2 server.
We will also need to clean up the connection once we are done with our work. The code below will establish the connection and dispose of it afterwards,.
Your next step will be to get a list of the tasks you wish to reassign.
Depending on the specific requirements the method to achieve this might vary, but for this example we are going to get all the tasks currently with a specific user as the task’s destination.
These are the tasks that currently appear in that user’s worklist. To do that we wil be creating a K2 WorkklistCriteriaFilter and passing that into a method which retrieves the WorklistItems from the server.
The following code accomplishes that:
Now you will have the list of items currently on User1’s K2 worklist in the items list. What we would like to do is to iterate over this list and then reassigning these items to the new user. There is however a little bit of a catch here in that items that has already been opened or allocated to the user, or which have gone to sleep, can not just be reassigned to another user. These items first need to be released, and then reassigned.
The following code section releases these items, and then reassigns them to the new user.
And now all User1’s tasks will be assigned to User2.
About Velocity IT
Velocity IT is a premium K2 partner with 15 year’s K2 experience. We are also K2 masters. We specialise in the design and delivery of K2 solutions in the UK and in Europe. On average, our K2 consultants have over 4 1/2 experience and are highly experienced with K2 blackpearl. Get in touch with Velocity IT for a free consultation conversation how our K2 services and solutions can transform your business processes.