Skip to main content
Jul 1, 2022 10:54 AM UTC
Solved

Is there a way to get users and their associated workitems?

For suppose if i have many workitems and they are assigned to multiple users.

 

can i get the users and workitems data like below?

 

Map<WTUser,Set<WorkItem>>

 

Key will be WTUser and Set of WorkItems as value.

 

@BjoernRueegg @HelesicPetr 

Jul 1, 2022 12:13 PM UTC

Hi @manoj_dokku2 

Have you ever try this one?

QueryResult QS = WorkflowHelper.service.getWorkItems(SessionHelper.getPrincipal());

Put there (WTUser)WTPrincipal object as a input . (I use sessionUser because it is the fastest way how to get user object :D)

 

PetrH 

 

 

5 replies

Jul 1, 2022 11:16 AM UTC

I do not think workItems can be assigned to multiple users. As an aside, I never understood why API is missing such critical class documentation. Perhaps its to hide internal functionality. Anyway, there are two methods which might work to find the user to a work item that I have used:

workItem.getOwnership().getOwner()

workItem.getDelegate() (returns WTPrincipalReference)

 

WfAssignedActivity can have multiple assignees (WorkItems). The StandardWorkflowService has methods to get assignees from a WfAssignedActivity.

 

 

 

Jul 1, 2022 11:21 AM UTC

I totally agree with you but, there is a chance where one user might be having many tasks assigned to him through multiple change notices.

Jul 1, 2022 12:13 PM UTC

True but that would be multiple workitems. Task=workitem. WorkItems are grouped to a WfAssignedActivity with a common role. You can see how it works when multiple people under same role have their own tasks. When a user accepts it, that workitem is deleted from the other user's list. if they unaccept it, the workitems are restored to the other users of that role.  

 

Note that the workflow process can be tied to any object, not just change objects. So you are looking to get a map from a change notice of all workitems and users. You only need a list of workitems active since there is a 1:1 tie to a user. From there, you can create your set.

 

take a look at getWorkItems methods in StandardWorkflowService API.

Jul 1, 2022 12:13 PM UTC

Hi @manoj_dokku2 

Have you ever try this one?

QueryResult QS = WorkflowHelper.service.getWorkItems(SessionHelper.getPrincipal());

Put there (WTUser)WTPrincipal object as a input . (I use sessionUser because it is the fastest way how to get user object :D)

 

PetrH 

 

 

Jul 1, 2022 2:20 PM UTC

Thank you so much.