cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X

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

manoj_dokku2
12-Amethyst

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 

ACCEPTED SOLUTION

Accepted Solutions

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 

 

 

View solution in original post

5 REPLIES 5

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.

 

 

 

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.

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.

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 

 

 

Thank you so much.

Announcements

Top Tags