It's all about the answers!

Ask a question

How to get value of State attribute?


pugazhenthi samidurai (26423742) | asked May 14 '12, 12:44 a.m.
Hi,

i am using plain java client for fetching all work items and its values.


But i am unable to get the value of State attribute.


Please also check my previous post.

https://jazz.net/forums/viewtopic.php?t=24762&highlight=

Please suggest any solution.

2 answers



permanent link
Paulo Cavoto (1111) | answered May 18 '12, 10:57 a.m.
Hi,

i am using plain java client for fetching all work items and its values.


But i am unable to get the value of State attribute.


Please also check my previous post.

https://jazz.net/forums/viewtopic.php?t=24762&highlight=

Please suggest any solution.


By reading you other topic, I assume you are only listing the custom attributes of a WorkItem, there are some attributes that you can get directly from the WI itself , the following example is from the server side, but it shouldn't be much different on the client.
To get the state use getState2() , it will return the ID of the state but not its name. To get the name, use the WorkflowInfo


IWorkItemServer workItemService = getService(IWorkItemServer.class);

IWorkflowInfo wfi = workItemService.findWorkflowInfo(workItem, monitor);
String statename = wfi.getStateName(workItem.getState2());

permanent link
pugazhenthi samidurai (26423742) | answered May 21 '12, 1:03 a.m.
Hi Paulo Cavoto,

Thank for your response.

Now i have fetched the state value.

I am using plain java client. check my code below.

ITeamRepository repository = RepositoryManager.getInstance().getCurrentRepository();
IWorkItemClient workItemService = (IWorkItemClient) repository.getClientLibrary(IWorkItemClient.class);
IWorkflowInfo wfi = null;
try {
wfi = workItemService.findWorkflowInfo(workitem, null);
} catch (TeamRepositoryException e) {
e.printStackTrace();
}
String statename = wfi.getStateName(workitem.getState2());

Your answer


Register or to post your answer.