Setting / updating work item attribute value using the java api
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.
I can even print out the work item info, so I have the correct state:
but I keep getting the error:
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); workingCpy.save(jazzAPI.monitor);
I can even print out the work item info, so I have the correct state:
Now processing work item [70] with info [Proxy of com.ibm.team.workitem.common.internal.model.impl.WorkItemImpl@e880e88 (stateId: [UUID _dzLYICzAEeKnM9g6W2GS7g], itemId: [UUID _KyWLgCzAEeKuBMMvbWuwXw], origin: com.ibm.team.repository.client.internal.TeamRepository@7eca7eca, 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(Assert.java:85) at org.eclipse.core.runtime.Assert.isNotNull(Assert.java:73) at com.ibm.team.workitem.client.internal.WorkItemWorkingCopyRegistry.getWorkingCopy(WorkItemWorkingCopyRegistry.java:739) at com.ibm.team.workitem.client.internal.WorkItemWorkingCopyManager.getWorkingCopy(WorkItemWorkingCopyManager.java:98) at rtctool.RTCAdminTool.searchAttributeUsage(RTCAdminTool.java:291) at rtctool.RTCAdminTool.handleChoice(RTCAdminTool.java:141) at rtctool.RTCAdminTool.main(RTCAdminTool.java:95)I get the error when I call .getWorkingCopy(). Any ideas?
Accepted answer
Hi Morten,
I think you need to call manager.connect() before calling getWorkingCopy(). My code looks like this:
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();