It's all about the answers!

Ask a question

How can I get a STATE Name of workitem in RTCClientplainJava


Imran Akbar (56278) | asked Feb 10 '12, 1:37 a.m.
Hi,

i hope this is a simple Question.

I want to get the STATE name of a work item, i tried with the below code it returns the State not the Name.

workItem.getState2().getStringIdentifier()

Accepted answer


permanent link
Indrajeet Singh (26) | answered Jul 11 '18, 8:42 a.m.

It's very old question but I hope it will help someone.

private String getStateName(IWorkItem workItem, IProgressMonitor monitor) throws TeamRepositoryException {
 if (workItem != null) {
  Identifier<IState> state = workItem.getState2();
  IWorkflowInfo workflowInfo = workItemClient.findWorkflowInfo(workItem, monitor);
  return workflowInfo.getStateName(state);      
 }
 return null;
}

Ralph Schoon selected this answer as the correct answer

2 other answers



permanent link
sam detweiler (12.5k6195201) | answered Feb 10 '12, 8:24 a.m.
I don't know how to get the first data item in a client

but here is a snippet of code I use in an Advisor.
you need the IWorkflowInfo object for this workitem.

				IAuditableCommon iac = &#40;&#40;ISaveParameter&#41; data&#41;.getSaveOperationParameter&#40;&#41;.getAuditableCommon&#40;&#41;;

WorkflowManager wfm = new WorkflowManager&#40;iac&#41;;

// reference the right object type &#40;cast&#41;
IWorkItem workItem = &#40;IWorkItem&#41; auditable;
// get the workflow this workitem is in, so we can get the labels of the states
IWorkflowInfo x =wfm.getWorkflowInfo&#40;workItem, monitor&#41;;

if&#40;Debug&#41; System.out.println&#40;&quot;the workitem state is &quot;+ workItem.getState2&#40;&#41;.getStringIdentifier&#40;&#41;+ &quot;=&quot; +x.getStateName&#40;workItem.getState2&#40;&#41;&#41; &#41;;
// if this workitem is going into resolved state &#40;we accessed 'proposed new' state above
if&#40;x.getStateName&#40;workItem.getState2&#40;&#41;&#41;.equalsIgnoreCase&#40;ResolvedState&#41;&#41;

permanent link
SEC Servizi (97123559) | answered Feb 15 '12, 10:54 a.m.

I want to get the STATE name of a work item, i tried with the below code it returns the State not the Name.

workItem.getState2().getStringIdentifier()

We found a solution in this post: https://jazz.net/forums/viewtopic.php?p=74030#74030
But that method
com.ibm.team.workitem.client.WorkflowUtilities.findWorkflowInfo&#40;IWorkItem, IProgressMonitor&#41;.getStateName&#40;Identifier&lt;IState&gt;&#41;
is not very perfomant... :?

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.