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 :
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.
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
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'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.