How to get and update the status of the work item via Java API?
IWorkItem workItem .....;
IWorkItemHandle handle = (IWorkItemHandle) workItem.getItemHandle();
IWorkItemWorkingCopyManager wcm = workItemClient
.getWorkItemWorkingCopyManager();
wcm.connect(handle, IWorkItem.FULL_PROFILE, null);
WorkItemWorkingCopy wc = wcm.getWorkingCopy(handle);
IWorkItem copiedWorkItem = wc.getWorkItem();
IAttribute statusAttribute= workItemClient.findAttribute(projectArea, IWorkItem.STATE_PROPERTY, monitor);
IWorkflowInfo workflowInfo = workItemClient.findWorkflowInfo(copiedWorkItem, monitor);
String currentStatus = workflowInfo.getStateName(copiedWorkItem.getState2()); // I have gotten the current status of the work item.
Now I want to change the status but failed via either of the following two ways.
Way 1:
wc.setWorkflowAction("In Progress");
Way 2:
Identifier <IState> [] allStatus = workflowInfo.getAllStateIds();
copiedWorkItem.setState2(allStatus[2]);
Seems I used the right API but the status was not changed on RTC.
One answer
There is blog article written by our colleague.
http://rsjazz.wordpress.com/2012/11/26/manipulating-work-item-states/
There is a sample code in the middle of the blog entry. I recommend to subscribe this blog as we will get notification of sample codes !
http://rsjazz.wordpress.com/2012/11/26/manipulating-work-item-states/
There is a sample code in the middle of the blog entry. I recommend to subscribe this blog as we will get notification of sample codes !
Comments
Takehiko,
I am not sure your total thinking. Who will call saveWorkItem2 or saveWorkItem3?
Can you paste your code here?
If you are in China, Wordpress is blocked in China, you can try http://rsjazz.wordpress.com.nyud.net instead, it has worked for some people.
The code I use to find the state is downloadable here: http://dl.dropbox.com/u/12668004/UpdateParentParticipants/20121127_UpdateParentParticipants.zip
Comments
Takehiko Amano
JAZZ DEVELOPER Mar 12 '13, 1:14 a.m.Have you saved the workitem ( saveWorkItem2 or saveWorkItem3) ? I don't see the code in the list.