It's all about the answers!

Ask a question

How to get value for State and Priority attributes.

pugazhenthi samidurai (26423742) | asked May 04 '12, 1:02 a.m.

I am using plain java client for fetching all work items.

i am Using the below function for retrieve contributors.

public static String getContributorsValue(IContributorHandle contributorval)

ITeamRepository repository = RepositoryManager.getInstance().getCurrentRepository();

IItemManager itm = repository.itemManager();
IContributor contributor = null;

try {
contributor = (IContributor) itm.fetchCompleteItem(contributorval, IItemManager.DEFAULT, null);
} catch (TeamRepositoryException e) {
// TODO Auto-generated catch block

return contributor.getName();


Let me know How to get the Values of State and Priority instead of literal.

Accepted answer

permanent link
sam detweiler (12.5k6189201) | answered May 04 '12, 9:22 a.m.
here is my code used on the server for finding all the values of all the attributes of a workitem..
you need to change IWorkItemCommon to IWorkItemClient. (and use the getclient for IWorkItemClient).

				// reference the right object type (cast)

IWorkItem workItem = (IWorkItem) auditable;
IWorkItemCommon workItemCommon = iac.getPeer(IWorkItemCommon.class);
// get all the attributes in this project area
for(IAttribute ia:workItemCommon.findAttributes(p.getOldProcessArea().getProjectArea(), monitor) )
// check to see if the attribute is used in this workitem
System.out.println("processing for variable="+ia.getDisplayName()+" attrib type="+ia.getAttributeType());
// attempt to get the eumeration for this attribute
// will fail if not an enum
IEnumeration<ILiteral> enumeration = (IEnumeration<ILiteral>)workItemCommon.resolveEnumeration(ia, monitor);
String[] iaval = ia.getValue(iac, workItem, monitor).toString().split(":");

if(iaval.length>1 && iaval[1]!=null)
List<ILiteral> enumerationLiterals = enumeration.getEnumerationLiterals();
for (ILiteral literal : enumerationLiterals)
System.out.println("attribute name="+ia.getIdentifier() +", type"+"="+ia.getAttributeType()+" literal="+literal.getIdentifier2().getStringIdentifier()+" literal name="+literal.getName());
catch (Exception e)
pugazhenthi samidurai selected this answer as the correct answer

One other answer

permanent link
pugazhenthi samidurai (26423742) | answered May 07 '12, 6:03 a.m.
Hi sam,

Thank you for your response.

Now i can able to retrieve priority attribute value and literal.

But it not fetching the value of Status attribute.

Is there any solution.

Gustavo Leyva commented Aug 05 '12, 5:20 p.m.


Here is my code to obtain the value of Status attribute

returnAttribute.status = ((IWorkItemClient)repo.getClientLibrary(IWorkItemClient.class)).findWorkflowInfo(workItem, null).getStateName(workItem.getState2());

Your answer

Register or to post your answer.