Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

How can I get a STATE Name of workitem in RTCClientplainJava

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()

0 votes


Accepted answer

Permanent link

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

0 votes


2 other answers

Permanent link
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;

1 vote


Permanent link

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... :?

0 votes

Your answer

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

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,939

Question asked: Feb 10 '12, 1:37 a.m.

Question was seen: 7,035 times

Last updated: Jul 11 '18, 8:42 a.m.

Confirmation Cancel Confirm