How to release a work item locked by another user.

  • 27 March 2010
  • 5 replies
  • 3 views

Badge +1

Hi,


     In my InfoPath K2 BlackPearl Workflow, I'm assigning an activity to mutiple users and configured to generate one slot. So as soon as the work item is opened by one of the user it would be locked and disappear from other users K2 work list. The problem we have is if a user locks the item and takes off for a vacation or out-off ofice for a while it is becoming a bottle neck. What I need to do is provide a function (may be button) to end user to release a work item if it is locked. I created a web service using K2 API to release work item but it doesn't work the way I wanted. It works by releasing a work item that I locked but won't release work items locked by other users. I tried running the web service using K2 Service account but that didn't help. Our business does not want to use K2 Out-of-office or other out look integration features.


Also is there is any way to find who locked a work item based on serial # or Folio?


Please let me know if there is way to get around this problem.


 


Thanks


Ram


 


5 replies

Badge +5

Hi Ram,


Using the Workflow.Client API you can retrieve the "AllocatedUser" property on a "WorklistItem", which should be the user that has the specified worklist item allocated.


Hope this helps.


Gert

Badge +1

Thanks Gret.


I'm still wondering how to release a work item that is locked by other user. As I had mentioned in my initial post, I can release a work item that I locked (via a web service) but I can't release a work item that some one else has locked.


Any idea?

Badge +1

To get the username who opened the work item this helped:


http://www.k2underground.com/blogs/fromthebench/archive/2008/03/24/how-to-programatically-determine-what-user-s-opened-a-worklist-item-for-a-currently-active-client-event-instance.aspx


 


But still wondering how I can release the work item locked by another user.

Badge +4

Hi,


I believe you could redirect the work item to another user.


For doing so, you will have to impersonate the user who has locked the work item.


This will require Impersonate rights at server level.


Hope this helps.


Rgds,


Ritesh

Badge +8

For this you will need to execute 2 calls:
The first would be to get the ID of the Worklist item (not the same as serial number)
Then call the release method to make it available


Example:


using Mng = SourceCode.Workflow.Management;

.......

Mng.WorkflowManagementServer oS = new Mng.WorkflowManagementServer();




try
{
    oS.CreateConnection();
    oS.Connection.Open("myConnStr");


    Mng.Criteria.WorklistCriteriaFilter cr = new Mng.Criteria.WorklistCriteriaFilter();


 


    cr.AddRegularFilter(Mng.WorklistFields.Folio, Mng.Criteria.Comparison.Equals, "11"); // Filter by folio
    cr.AddRegularFilter(Mng.WorklistFields.Destination, Mng.Criteria.Comparison.Like, "%K2student%"); // Filter by destination
    Mng.WorklistItems its = oS.GetWorklistItems(cr);
    // Check Status, if not open, exception is raised when releasing


    if (its[0].Status == Mng.WorklistItem.WorklistStatus.Open)  // Assuming you only get 1 back, better to test if there is 1 and if the serial no match  
        oS.ReleaseWorklistItem(its[0].ID);
}
finally
{
    if (oS.Connection != null && oS.Connection.IsConnected)
        oS.Connection.Close();

    oS = null;
}


To test the serial no, use the its[0].ActInstDestID and its[0].ProcInstID fields. Also remember that the account executing this will need admin permissions.

Reply