Add workitem owner to project members RTC extension
Hi,
WorkItem workItem = (IWorkItem)auditable; IWorkItemServer workItemServer = (IWorkItemServer)getService(IWorkItemServer.class); IWorkItem workItemCopy = (IWorkItem)((IWorkItem)workItemServer.getAuditableCommon().resolveAuditable(workItem, IWorkItem.FULL_PROFILE, monitor)).getWorkingCopy(); IProcessArea proc = operation.getProcessArea();But I'm getting ImmutablePropertyException in line proc.AddMember(workItemCopy.getOwner()). What is the problem? How can I properly add members to project area? |
2 answers
Hi Ralph,
IWorkItem workItem = (IWorkItem)auditable; IWorkItemServer workItemServer = (IWorkItemServer)getService(IWorkItemServer.class); |
Ralph Schoon (63.5k●3●36●46)
| answered Apr 13 '17, 5:14 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER edited Apr 13 '17, 5:34 a.m.
As explained in https://rsjazz.wordpress.com/2013/03/20/understanding-and-using-the-rtc-java-client-api/ you need a working copy to change most objects.
In this example it would look similar to
private IProjectArea addUsersAndRoles(ITeamRepository teamRepository, IProjectArea area, IProgressMonitor monitor) throws TeamRepositoryException {For the server API it should look similar to IProcessItemService service = (IProcessItemService) getService(IProcessItemService.class); area = (IProjectArea) service.getMutableCopy(area);You also have to save the change later. e.g. below. Please note the different call to get a working copy. /* * Adds a user as a member with a specific role to a process area * * @param user * @param role * @param processArea * @param itemService * @param monitor * @throws TeamRepositoryException / public static void addMemberToProcessArea(IContributor user, IRole role, IProcessArea processArea, IProcessItemService itemService, IProgressMonitor monitor) throws TeamRepositoryException { IProcessAreaWorkingCopy areaWc = (IProcessAreaWorkingCopy) itemService .getWorkingCopyManager().createPrivateWorkingCopy( processArea); areaWc.getTeam().addContributorsSettingRoleCast( new IContributor[] { user }, new IRole[] { role }); areaWc.save(monitor); } Comments
Ralph Schoon
commented Apr 13 '17, 5:19 a.m.
| edited Apr 13 '17, 5:19 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
In general, I think you can overshoot with automation. I am not a friend of automating administrative duties in a follow up action/participant.
Please also note that the participant is run in the context of the user that performs the work item save. If this user is not a member of the project area and does not have permission to alter and save the project area process (which is usually an administrator or project owner role privilege) the operation to add the owner will fail.
No, there is no way to elevate your role to an administrator in a participant, if you are not already an administrator.
Marcin Blacha
commented Apr 13 '17, 6:10 a.m.
The main problem why I'm trying to create such participant is that access to project areas is restricted, but people are adding tasks and assign them to guys who are not members of project area, and they don't get mail notifications about this tasks. Do you have idea how to workaround this problem?
|
Your answer
Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.