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

Altering a work item

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.

0 votes



2 answers

Permanent link
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.

0 votes


Permanent link
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

0 votes

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,938

Question asked: Aug 24 '11, 11:35 a.m.

Question was seen: 4,554 times

Last updated: Aug 24 '11, 11:35 a.m.

Confirmation Cancel Confirm