It's all about the answers!

Ask a question

How to get and update the status of the work item via Java API?


0
1
Jayee Huang (1321111) | asked Mar 11 '13, 11:55 p.m.
 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.


Comments
Takehiko Amano commented Mar 12 '13, 1:14 a.m. | edited Mar 12 '13, 1:14 a.m.
JAZZ DEVELOPER

Have you saved the workitem ( saveWorkItem2 or saveWorkItem3) ?  I don't see the code in the list.


One answer



permanent link
Takehiko Amano (1.3k3741) | answered Mar 12 '13, 2:09 a.m.
JAZZ DEVELOPER
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 !




Comments
Jayee Huang commented Mar 12 '13, 1:32 a.m. | edited Mar 12 '13, 2:20 a.m.

 Takehiko,


I am not sure your total thinking. Who will call saveWorkItem2 or saveWorkItem3? 
Can you paste your code here?


Ralph Schoon commented Mar 12 '13, 2:16 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

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

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.