How to set a Contributor field to Assigned with Java API
Hello masters,
I am developing a plugin that update some attributes, including one of type "Contributor". Based on a condition, I have to set this contributor to "Unassigned". Follow my code: IAttribute tecnicoUGE = wiCommon.findAttribute(workItem.getProjectArea(), "tecnico_responsavel_uge", monitor); IRepositoryItemService repositorio = getService(IRepositoryItemService.class); IContributorHandle handleTecUge = (IContributorHandle) workingCopy.getValue(tecnicoUGE); IContributor tecUGE = (IContributor) repositorio.fetchItem(handleTecUge, IRepositoryItemService.COMPLETE); tecUGE.setName("Unassigned"); When setName is executed, the followin exception is raised: 13:29:44,585 [2058648244@qtp-1401967504-35 @@ 13:29 TestJazzAdmin1 /jazz/service/com.ibm.team.workitem.common.internal.rest.IWorkItemRestService/workItem2] ERROR com.ibm.team.process.common - com.ibm.team.repository.common.internal.ImmutablePropertyException What am I doing wrong? How to set "unassigned" to attribute of Contributor type? Thanks for any help. |
Accepted answer
>tecUGE.setName("Unassigned");
U are attempting to change the Contributors (users) name.. that is not allowed. You want to change the ATTRIBUTE's value to Unassigned (which may be the default, or the null value) tecnicoUGE.getDefaultvalue(....) (see the Javadoc) then IWorkItem.setValue(tecnicoUGE, default_value), see the javadoc (this make sense because attributes only exist in the context of a workitem.) might also be the Nullvalue tecnicoUGE.getNullValue(...) see the javadoc also, your topic title says 'Assigned', but your text says 'Unassigned'.. if you want to assign to a specific user IContributorHandle newOwner; then IWorkItem.setValue(tecnicoUGE, newOwner); Luiz Almeida selected this answer as the correct answer
|
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.