It's all about the answers!

Ask a question

Setting / updating work item attribute value using the java api

Morten Madsen (3053250) | asked Nov 14 '12, 8:14 a.m.
edited Nov 14 '12, 8:18 a.m.
Hi, I've read a lot of the other posts about this, and I just can't get this to work.

I basically want to call "setValue(IAttribute, Object)" on a work item, and my approach is this:
EDIT: "att" is an IAttribute.
wi = (IWorkItem) jazzAPI.fetchCompleteItem(wi);
val = wi.getValue(att).toString();

sayln("Now processing work item ["+wi.getId()+"] with info ["+wi.toString()+"]");
WorkItemWorkingCopy workingCpy = jazzAPI.getWorkItemClient().getWorkItemWorkingCopyManager().getWorkingCopy(wi);
val = val.replaceAll(replaceFrom, replaceTo);
workingCpy.getWorkItem().setValue(att, val);;

I can even print out the work item info, so I have the correct state:
Now processing work item [70] with info [Proxy of (stateId: [UUID _dzLYICzAEeKnM9g6W2GS7g], itemId: [UUID _KyWLgCzAEeKuBMMvbWuwXw], origin:, immutable: true) (contextId: [UUID _hPM_oCyrEeKuBMMvbWuwXw], modified: 2012-11-12 12:59:51.97, workingCopy: <unset>) (mergePredecessor: null, workingCopyPredecessor: <unset>, workingCopyMergePredecessor: <unset>, predecessor: [UUID _Uoz6ZizAEeKnM9g6W2GS7g]) (id: 70, internalState: BDworkflow.state.s3, internalResolution: , resolutionDate: null, summary: mybd, internalSeverity: , creationDate: 2012-11-12 12:58:50.47, internalPriority: priority.literal.l01, dueDate: null, description: asd, workflowSurrogate: , internalTags: , workItemType: bd, duration: -1, timeSpent: -1, internalSequenceValue: null, correctedEstimate: -1, startDate: null, archived: false)]

but I keep getting the error:
org.eclipse.core.runtime.AssertionFailedException: null argument:
	at org.eclipse.core.runtime.Assert.isNotNull(
	at org.eclipse.core.runtime.Assert.isNotNull(
	at rtctool.RTCAdminTool.searchAttributeUsage(
	at rtctool.RTCAdminTool.handleChoice(
	at rtctool.RTCAdminTool.main(

I get the error when I call .getWorkingCopy(). Any ideas?

Accepted answer

permanent link
Lauren Hayward Schaefer (3.3k11727) | answered Nov 15 '12, 7:53 a.m.
Hi Morten,

I think you need to call manager.connect() before calling getWorkingCopy().  My code looks like this:

IWorkItemClient workItemClient= (IWorkItemClient)teamRepository.getClientLibrary(IWorkItemClient.class);
IWorkItemWorkingCopyManager manager= workItemClient.getWorkItemWorkingCopyManager();
manager.connect(workItemHandle, IWorkItem.SMALL_PROFILE, progress.newChild(20));
IWorkItem workItem= null;
WorkItemWorkingCopy copy= manager.getWorkingCopy(workItemHandle);
workItem= copy.getWorkItem();
Morten Madsen selected this answer as the correct answer

Morten Madsen commented Nov 16 '12, 2:59 a.m.


Lauren Hayward Schaefer commented Nov 16 '12, 7:04 a.m.

You're welcome! :-)

Your answer

Register or 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.