Skip to main content
12-Amethyst
July 1, 2022
Solved

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

  • July 1, 2022
  • 2 replies
  • 2579 views

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 

Best answer by HelesicPetr

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 

 

 

2 replies

avillanueva
23-Emerald I
23-Emerald I
July 1, 2022

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.

 

 

 

12-Amethyst
July 1, 2022

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.

avillanueva
23-Emerald I
23-Emerald I
July 1, 2022

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.

HelesicPetr
22-Sapphire II
22-Sapphire II
July 1, 2022

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 

 

 

12-Amethyst
July 1, 2022

Thank you so much.