Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

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.

0 votes


Accepted answer

Permanent link
>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 DE ALMEIDA selected this answer as the correct answer

1 vote

Comments

Thank you, Sam.

Your answer

Register or log in to post 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,936

Question asked: Oct 14 '14, 12:33 p.m.

Question was seen: 2,980 times

Last updated: Oct 14 '14, 5:39 p.m.

Confirmation Cancel Confirm