It's all about the answers!

Ask a question

Altering a work item


Laurence Caraccio (9166) | asked Aug 24 '11, 11:35 a.m.
I've got the work item I want to alter (by id) but when I try something like workItem.setHTMLSummary(XMLString.createFromPlainText("Test Editing work item")); to change the summary it throw an exception saying the work item is immutable which can't be changed, here's what I've got so far :

 IWorkItemHandle handle = (IWorkItemHandle) workItem.getItemHandle();

IWorkItemWorkingCopyManager wcm = workItemClient.getWorkItemWorkingCopyManager();
wcm.connect(handle, IWorkItem.FULL_PROFILE, null);
WorkItemWorkingCopy wc;

wc = wcm.getWorkingCopy(handle);
IWorkItem copiedWorkItem = wc.getWorkItem();

copiedWorkItem.setHTMLSummary(XMLString.createFromPlainText("Test Editing work item"));

IAttribute stateAttribute = workItemClient.findAttribute(projectArea, IWorkItem.STATE_PROPERTY, null);

copiedWorkItem.setValue(stateAttribute, null);

wc.save(null);

I'm also aware that in wc.save and copiedWorkItem.setValue I need a monitor but I'm not sure what kind to use.

Any help with this matter would be greatly appreciated.

2 answers



permanent link
David Van Herzele (10121) | answered Aug 30 '11, 4:40 a.m.
Check with the isImmutable() method to make sure you can alter the workitem instance.

I'm don't have any experience trying to do this client side, but you should be able to extract a mutable version with the getWorkingCopy method.

I've got the work item I want to alter (by id) but when I try something like workItem.setHTMLSummary(XMLString.createFromPlainText("Test Editing work item")); to change the summary it throw an exception saying the work item is immutable which can't be changed, here's what I've got so far :

 IWorkItemHandle handle = (IWorkItemHandle) workItem.getItemHandle();

IWorkItemWorkingCopyManager wcm = workItemClient.getWorkItemWorkingCopyManager();
wcm.connect(handle, IWorkItem.FULL_PROFILE, null);
WorkItemWorkingCopy wc;

wc = wcm.getWorkingCopy(handle);
IWorkItem copiedWorkItem = wc.getWorkItem();

copiedWorkItem.setHTMLSummary(XMLString.createFromPlainText("Test Editing work item"));

IAttribute stateAttribute = workItemClient.findAttribute(projectArea, IWorkItem.STATE_PROPERTY, null);

copiedWorkItem.setValue(stateAttribute, null);

wc.save(null);

I'm also aware that in wc.save and copiedWorkItem.setValue I need a monitor but I'm not sure what kind to use.

Any help with this matter would be greatly appreciated.

permanent link
Laurence Caraccio (9166) | answered Aug 30 '11, 5:34 a.m.
Turns out my code works I just needed to close the online access to the repository and re-open it before the changes showed up, silly me

Your answer


Register or to post your answer.