It's all about the answers!

Ask a question

Ho to fetch workitem type attribute value?

pugazhenthi samidurai (26423942) | asked May 08 '12, 5:01 a.m.

i am using plain java for fetching all work items from project area.

i have one doubt how to fetch value for work item type attribute.

6 answers

permanent link
Ralph Schoon (63.2k33646) | answered May 08 '12, 6:51 a.m.
Please see:

In a nutshell

Find the attribute

IAttribute customString = workItemClient.findAttribute(fProjectArea,
fCustomStringAttributeID, null);

Or iterate the exiting ones:

// List Custom Attributes
List<IAttributeHandle> custAttribs = workItem.getCustomAttributes();
for (Iterator<IAttributeHandle> iterator = custAttribs.iterator(); iterator.hasNext();) {
IAttributeHandle iAttributeHandle = (IAttributeHandle) iterator
IAttribute iAttribute = (IAttribute)fTeamRepository.itemManager().fetchCompleteItem(iAttributeHandle, 0, null);
System.out.print("Custom: " +iAttribute.getIdentifier()+" \t" +iAttribute.getDisplayName()+" \t"+iAttribute.getAttributeType());
Object value = workItem.getValue(iAttribute);
if(value!=null && value instanceof String) {
String sValue = (String) value;
System.out.print("\tValue: " + sValue);

You get the value as an object and need to cast it. Enumerations return ILiteral or something like that. I have no code snippet lying around for that case.

permanent link
sam detweiler (12.5k6195201) | answered May 08 '12, 8:31 a.m.
My code for finding the values of ALL attributes in a workitem (including enumerations) is here

but if you are asking how to find the workitem TYPES in a project..

the call is

workItemClient.findWorkItemTypes(fProjectArea, monitor)


permanent link
pugazhenthi samidurai (26423942) | answered May 08 '12, 10:19 a.m.
Hi Sam,

Thank you very much.

Based on your post ( .

i have found the solution for retrieving priority and other values like enumeration , string type values.

But i am unable to retrieve Status (interanalState) attribute and work item type attributes values.

permanent link
pugazhenthi samidurai (26423942) | answered May 08 '12, 10:36 a.m.
Hi Ralph Schoon,

Thank you for your response.

i have followed your post.

check my output below for this line,

System.out.print("Custom: " +customString.getIdentifier()+" \t" +customString.getDisplayName()+" \t"+customString.getAttributeType());


Custom: customerid Customer ID workItem

And it doesn't return any value for work item type of attribute.

permanent link
Ralph Schoon (63.2k33646) | answered May 08 '12, 11:02 a.m.

If I read your output correctly it says that the attribute Type identifier returned by IAttribute.getAttributeType() is "workItem".

So I would assume that it was configured to contain work items. Is that not correct?

If you are talking about the state of a work item, the work item has getters and setters for the built in attributes that you can use too.

permanent link
pugazhenthi samidurai (26423942) | answered May 09 '12, 12:22 a.m.
Hi Ralph Schoon,

its correct one of my attribute type is work item.

Please suggest me how to get the value of that attribute(work item type).

And also i am unable to fetch the value of State attribute.

Sorry for my inappropriate post.

I want to read the values of two attributes.

1. work item type attribute
2. State type attribute.

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.