+44(0)1908 545 770
YOUR EXPERT RPA PARTNER

Team up with our RPA strategy and tech specialists for maximum automation impact

Find out more
Harness the power of UiPath in your business.
WATCH NOW

Save money and spend more time on priority work.

Book consultation
READY, SET, AUTOMATE

Let's choose, design and deploy a process automation solution for your business.

Find out more
TRANSFORM YOUR BUSINESS

Let's analyse your business to discover opportunities for innovation and automation.

Find out more

Begin your business transformation journey

Book consultation
AUTOMATE EVERY FUNCTION

Automate where it matters most. Scale to solve challenges in every area

Find out more
GIVE EVERY TEAM THE TOOLS FOR SUCCESS

Equip people with user-friendly solutions that save time and make work easier

Find out more

Which business problem
can we solve first?

Book consultation
25 March 2015

How to release and reassign a user’s K2 worklist tasks in code using C#

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.

Image 1 - Release and reassign a task using K2 Workspace

Image 1 – Release and reassign a task using K2 Workspace

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.

 

Free K2 Five Upgrade Review

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,.

Image 2 - Open a connection to K2 Management API

Image 2 – Open a connection to K2 Management API

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:

Image 3 - Setup the Worklist Filter Criteria

Image 3 – Setup the Worklist Filter Criteria

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.

Image 4 - Release and Redirect K2 Task

Image 4 – Release and Redirect K2 Task

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.

Need further technical advice or support?