Assigning Activity to Current User

  • 4 December 2007
  • 2 replies
  • 1 view

Badge +9

I have used a Client Event to assign an activity to a Role, which successfully creates worklist items for each user in the role.  What I want to do, more for an exercise than any business need, is to allow a user to 'Claim' said workitem, which removes it from everyone else's work list.  To do this, I've made a 'Claim' outcome of the main activity, which effectively closes the main activity and creates a new one, with the intent of making the destination user whover just closed the main activity.  Trolling the forums gave me the idea that I'd need to set a data field equal to the ActivityInstanceDestination.User.Name like this:


K2.ProcessInstance.DataFields[

"CurrentUser"].Value = K2.ActivityInstanceDestination.User.Name;


However, I'm not where sure *where* to make this call (I am a total beginner to blackpearl, K2 and workflow in general, so the simpler the answer the better!)


I've tried creating a server event in both the main activity and the 'Claim' activity (tied to the main activity via the 'Claim' outcome) and setting the desitnation user of my 'Claim' activity to the CurrentUser data field.  The result of the former is an 'Object reference not set to an instance an object' error when trying to retrieve the activity instance destination and the result of the latter is the process going into limbo (it is marked as 'Running' in the workspace forever and does not appear on anyone's task list).


Am I going about this a totally backwards way?  Even if there is a better approach, why doesn't what I am doing with the activity instance destination work?


2 replies

Badge +8

The default destination rule configuration "Plan Just Once" will create one worklist item that all the users share which means that you cannot access the ActivityInstanceDestination context.  If you change the destination rule configuration to "Plan per destination all at once" by clicking back on the destination rule, selecting advanced mode, and then clicking next, you should be able to set the datafield in a server event in the main activity (make sure this server event is after the client event since they execute in order).  By doing this you should not get the object reference error and allow the datafield to be used as the destination for the secondary activity.


 I hope this helps.


Eric

Badge +13

[Edited 11/3/2014] 4.6.7 I set as Plan per destination, all at once.  Next screen, specify # of slots to be created to be 1.   Create a slot for each role and group.

When the user from the Role completed, K2.ActivityInstanceDestination.User.Name showed the name of the Role instead of the user.

 

I have to use Plan Per Destination, All at Once to get the actual user completed the workitem.

http://blog.mgallen.com/?p=123

 

I opened a support ticket to see in the future release if we can get the completed user ID via "Plan Just Once", since "Plan Per Destination" has quite a bit of overhead not to mention it executes server events once per "Plan".

Reply