How to delegate/Redirect K2 task using K2 API

Hello All, Can somebody help me in how to delegate/redirect a K2 task using C# K2 API.

5 replies

Hi Srikanth,

Here is the code to delegate or redirect a K2 task, it uses K2 client API's:

1. Code to redirect or delegate own task:

using K2 = SourceCode.Workflow.Client;
 //Pass K2 SN and Redirect Or Delegate user id
public void RedirectOrDelegateK2Task(string serialNumber, string userFQN)
            K2.WorklistItem wli = null;
            K2.Connection con = null;

                con = new K2.Connection();
                con.Open("[Blackperal Server Name]");
                con.ImpersonateUser("[Domin Name]\" + userFQN);
                wli = con.OpenWorklistItem(serialNumber);
                //code to redirect
                wli.Redirect("[Domin Name]\[Redirect To User ID (FQN)]"); //Example:- K2\UserA
                //code to delegate
                K2.Destination _Destination = new K2.Destination();
                //Allow actions to delegated user
                foreach (K2.Action _action in wli.Actions)
                _Destination.DestinationType = SourceCode.Workflow.Client.DestinationType.User;
                _Destination.Name = "[Domin Name]\[Redirect To User ID (FQN)]"; //Example:- K2\UserA
               if (con != null)

Thanks for the reply, its useful.

In my scenario, i am trying to remove a group/user 'Task Completed' action through k2 api. But i am unable to achieve. Any idea on that.

Also i wanted to disable task completed checkbox for User2 from K2 worklist (User 1 should able to see and complete the task). How can i achieve this.

I am not sure i completely understand what you are trying to do here.  You want to remove one of the actions an user can take from a process via the API at runtime?  


Can you elaborate perhaps give an example of use?

Hello Chrisg.

here is the scenario where the task  page will be opened for two users for example user 1 and user 2, but only user 1 can  perform the action ,user 2 must not  perform the action but still he can read the action page.

And also for the user 2  action must be disabled.

Thank u


After redirecting the task using K2 API, it doesn't update K2 server log destination user is not updated to new user.

we are creating report based on that and it is still showing old user.

please let me know what is wrong.


WorklistItem worklistItem = k2Connection.OpenWorklistItem(serialNumber);
worklistItem.ProcessInstance.DataFields["TechnicianUser"].Value = user;