Skip to main content
I have following code:

myWorkListItem = myConnection.OpenWorklistItem(SN, "ASP", true, true);

...

if (myWorkListItem.Status == SourceCode.K2ROM.WorklistStatus.Allocated)
{
txtStatus.Text = "Item allocated";
}


I set the third parameter of OpenWorklistItem to 'true' so that the WorklistItem is allocated the current user. But why the Status never been "Allocated", it keep in "Open" status, what is the different between "Allocated" and "Open"

Thanks
WorklistItem Status:
Available = Any one of the destination users can still open and work on the item.
Open = I am the user who has this item open and will be working on it.
Allocated = Some other user has already opened the item and I'm too late.

OpenWorklistItem arguments:
Allocated = true - If 'IgnoreStatus' is also true, the WorklistItem will be "Open"-ed in the logged on user's name - irrespective of what the status of other worklist items are. If 'IgnoreStatus' is false, the worklist item will ONLY be "Open"-ed by this user if all other worklist item statuses were Available before you made this call.
IgnoreStatus = true - Exactly what it says - Disregard the status of all other worklist items.

Does this make sense?

Regards,
Ockert
May be I explain my problem.

My activity have multiple destination user.

I want in the web form, if the item is allocated to other user, then disable all the action button and show a message that the item is already allocated to other.

So i think i should check the WorkListItem.Status = "Allocated" in the form. But everytime I call OpenWorklistItem, the Status is "Open", so when will the WorklistItem.Status = "Allocated"??

Or alternative, can I access the data in a process instance with "Open" it??

Thanks
My activity have multiple destination user.
With 1 slot I assume.

I want in the web form, if the item is allocated to other user, then disable all the action button and show a message that the item is already allocated to other.
If you leave the 'Allocated' and 'IgnoreStatus' arguments false (default), the call to OpenWorklistItem should return an error IF the item is allocated to another user i.e. opened by another user. If you put this call in a Try - Catch block, you should be able to catch the error and handle appropriately.

Regards,
Ockert

Ok, how can i know the process is allocated by whom?
Hi,

The K2ROM does everything under the logged on or "connected" user credentials. It can not return information on the status of OTHER user's worklist items.

If you need to know the name of the user that has a worklist item opened in his/her own name, you will need to make use of the K2MNG object model. Here the catch is that you need K2Server Administrative permissions to log in through K2Mng. Please have a look at the Help file for samples. You'll probably need to utilize the K2Manager.GetWorkListItems method.

Regards,
Ockert
Is there a matrix on all the combinations to these 2 and the result of the status?

Are these assumptions correct:

1 slot, Allocated = True and IgnoreStatus = True.
User1 opens the item, now item has status of "Open" to User1.
Item has "Allocated" status to User2.
User2 can still open the item because IgnoreStatus = True, now User1 and User2 both see the item as "Open" in their worklist.

1 slot, Allocated = False and IgnoreStatus = True.
User1 opens the item, now item has status of "Open" to User1.
Item shows "Available" status to User2 because it's not allocated.
User2 opens the item, now both User1 and User2 see the item as "Open" in their worklist.

"Ockert" wrote:
WorklistItem Status:

OpenWorklistItem arguments:
Allocated = true - If 'IgnoreStatus' is also true, the WorklistItem will be "Open"-ed in the logged on user's name - irrespective of what the status of other worklist items are.

Hi Peter,

Once again - not tested but here is my understanding of the settings...

The 'Allocated' flag will determine whether the status of the worklist item is changed when it is opened i.e.
If Allocated = True, the status of the current worklist item will be changed to 'Open' for the logged on user and all other user's worklist item's status will change to 'Allocated'.
If Allocated = False, no change in worklist item status will be made i.e. all worklist item statuses will stay 'Available' even though some user has opened and viewed the corresponding client UI.

The 'IgnoreStatus' flag will determine whether statuses are considered when attempting to open a worklist item i.e.
If 'IgnoreStatus' = True, the worklist item will be opened under the current logged on user name irrespective of whether or not someone else has got the worklist item open i.e. even if this user's worklist item status was 'Allocated', he/she would be able to also open the item.
If 'IgnoreStatus' = False, the worklist item will ONLY be opened if the current logged on user's worklist item status is 'Open' or 'Available'. If the worklist item status is 'Allocated', the item will not be opened.

So, if we take a look at your assumptions:
Item shows "Available" status to User2 because it's not allocated.
True.

Hope this makes sense,
Ockert

Some sample code to handle what Ockert laid out:

 

public
static bool
IsValidWorklistItem(string UserToImpersonate, string SN)


    {


     
  bool m_isValidWorklistItem = true;




     
  SourceCode.Workflow.Client.Connection
conn = null;


     
  try


     
  {


     
     


     
      conn = OpenK2ServerConnection(UserToImpersonate);


     
     


     
      WorklistItem item =
conn.OpenWorklistItem(SN);




     
  }


     
  catch(Exception
ex)


     
  {


     
   


     
     


     
     m_isValidWorklistItem = false;

                      //replace line below with error/information to surface to user

     
     ex.Message.ToString();


     
 


     
  }


     
  finally


     
  {


     
      CloseK2ServerConnection(conn);


     
  }




     
  return m_isValidWorklistItem;




    }



 


Reply