Question

How to get the user who actioned the user task?


Hello all,


I created a one slot user task for a Sharepoint Group and i want to find the user who actioned the task. I tried this using the List method of the Activity Slot Data smartobject.


I've put a filter on Activity Instance ID with the ActivityInstanceId from the workflow context browser. But I don't get a result. (the workflow report for the activity does show the user who actioned the task)


Any ideas?


11 replies


One place where you can view who actioned is looking at the ViewFlow of the instance > Activity Summary > Participants tab. Think your destination rule will have an impact here. If you have not chosen the option to resolve all groups and roles to users then I think (Maybe wrong) it will only show the group in the participants tab, as the slot belonged to the group. When resolving the group to users then the slot will be taken up by the user actioning,


Or you can try capturing the user in a datafield in the process design...this way you can only look up the datafiled value.


ie:


drop a Server Event in the same activity below the client event. This sever event has a single line of code:


K2.ProcessInstance.DataFields["SlotUser"].Value = K2.ActivityInstanceDestination.ActivityInstance.WorklistSlots[0].User.FQN;


HTH


Vernon



 



 



 



 

Hi Vernon,


I've seen that you can find the user in the Viewflow and in the Proces Portal reports. But I need it in a datafield because this user gets even more after the first task.


I should have mentioned that I am working with K2 Studio, not Visual Studio. So no coding for me...
I would expect to find this in the Proces/Activity data, just like Outcome and Action Result


I tried your suggestion and resolved all groups and roles to users and then i could use the workflow context browser to find the user.
But the downside is, if my group is populated by 100 users, i would see 100 destinations in the management worklist.

Anyway, In the end I managed to do this.
I went back to 1 destination for the group. Then i used the Activity Instance Destination smartobject and filtered for Activity Instance ID.
That worked!


Cheers,
Lucien

 

Userlevel 4
Badge +3

I’ve tried using the Activity Instance Destination smartobject as well to resolve who actually performed the task. I found that though this works well in my virtual machine environment I found in my customers staging environment that sometimes it would not return the expected results. This is because the Activity Instance Destination smartobject is retrieving information from the K2ServerLog database and the updates to that database is not necessarily immediate from the K2Server transaction database based on load and other factors. So unless the Activity Instance Destination smartobject call is being done in a following activity where you could put a Start Rule delay on the activity, providing some time to update the K2ServerLog database, I do not think that you could rely on this technique.


The other technique about resolving all groups to users and reading the Context Browser Activity Destination User is what I typically use, although as you noted if there are a lot of destination users that can create overhead resolving all the users but also it will copy the data stored at the activity level for each resolved user. Not something I would recommend if using InfoPath integration or large XML fields inside the activity. The other downside of this technique is that if the task gets redirected the Activity Destination isn't updated inside the workflow so if you're reading the user from the Context browser it will show the original user not the redirected user.


Another technique that you can try is in the form itself you can typically get the windows account of who opened the form and save that information back into the process. This solves the redirect issue and the resolving the groups to users. However, because the form would need to be opened to get the current user you would need to remove the option to allow users to action their work from the K2 Worklist or from using the new SmartAction features.


So in summary currently I haven't found a technique that handles every scenario and I have to weigh the pros and cons of each based on the business requirements.  Hopefully someone else has found a solution that would handle all these scenarios and could comment on this post.


I hope this helps.


Tim


 

Tim,
My reaction seems to be a bit early.
Like you, I tried this in my virtual machine environment but in the actual development environment it didn't work.
I will try your suggestion and use a Start Rule in the next activity. Forgive me my ignorance, but is it possible to use the smartobject in a Preceding Rule and check for an empty value? Or does this mean that the next activity will never start?


Lucien

Userlevel 4
Badge +3

Hi Lucien


The mistake I made moving from my VM to the customer's environment was I forgot to give the K2 Service account "View" permissions on the process. Without that the Activity Destination SmartObject queries came back blank when executed in the workflow itself by the k2 Service account. I wonder if you're experienced the same issue.


You could use a SmartObject in a preceding rule to check for an empty value however if the preceding rule evaluates to false the activity will not start.


I guess potentially in the start rule you could use the If inline function that would do the query and if blank you could return a delay. However, that would be a one-time delay meaning if you delayed for 10 seconds and the K2Serverlog database still wasn't updated the process would error as the query would return blank when assigning the destination. I guess you could delay by something like 5 minutes (probably way too much of a delay but I'm being conservative) which would in all likelihood give the K2 Server plenty of time to write out the log information and in most processes a user isn't going to care if he gets his worklist item 5 minutes later


 

Hi Tim,

I found that you could also use the Last Item function on the (hidden) SPComments XML field.
That way it's also possible to retrieve the body of the comment.


Regards,
Lucien

In the end this didn´t work either. Due to the way the XML of the Comments field is build, it always returns the first comment.


Tims suggestion was the right one. Give the service account view permission and it can be done with the smartobject. I haven´t seen the timing problem yet.

Lucien

Hi,


I can see two ways of doing this :


- If your forms are ASP.Net forms : it's very eays to value a Datafield with the currently connected user (Connection.User.Name) on the action button event handler


- If your form is an InfoPath form, there are plenty tutorials to get the current user name, which you can then put in a datafield or access directly from the XML Fields.


 


However if your user trigger the action directly from the worklist, I don't know how you can get his name.


Regards

I had this same issue (version 4.6.5), the context browser solution works unless the user is OOF, or if the task is delegated to somebody else; As Tim explained.


I was able to use the Activity Instance Destination SmartObject in the next step, with a 5 second delay. I passed in the final action, folio, and activity name. I got back the destination. It's not as pretty as the display name, but it serves its purpose.


Here's to hoping they add a feature for this in the future that makes it a little more straight forward.

the Solution to determining the destination users for an activity at run time is to specify the Destination Rule planning option to be set to Plan per destination. This can be done via code behind the Client Event or a server event that precedes the Client Event. The user information is available via theK2.ActivityInstanceDestination.User object, which has properties for the username, FQN, e-mail

@K2IPIC, thanks. This works perfectly, changing the destination rule to "Plan per Destination", now I can get both the Participant name and ActivityDestinationInstanceUsername from the Context Browser directly in K2 Studio. 

 

 

Reply