It's all about the answers!

Ask a question

How to get CustomAttribute from Work Item?

Minghua Zhao (2122) | asked Dec 09 '13, 10:12 a.m.
I want to print out all of the Custom Attribute fields from a Work Item. Right now' I'm trying to do something like this:

List<IAttributeHandle> customAttributes = currentWI.getCustomAttributes();
          customAttributes = currentWI.getCustomAttributes();

for(int i = 0; i < customAttributes.size(); i++ ){               
IAttribute item = (IAttribute) this.repository.itemManager().fetchCompleteItem(
customAttributes.get(i), IWorkItem.PRIORITY_PROPERTY, null);
System.out.println( item.getDisplayName() );

How can I get the Attribute? Right now I'm getting an Item.

Also, I'm new at the API, so it would be nice if the explanation was "dummbed down" for me :)

On the same token, it would also help if someone has knowledge of more explanatory documentation from the javadoc.

One answer

permanent link
Ralph Schoon (63.3k33646) | answered Dec 09 '13, 10:50 a.m.

please start here: and here

Your question should be answered in the second link above and in as well as in other posts.

You have to cast attribute values to the types expected. e.g. string, int, contributor etc. I think there are numerous examples on my blog.

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.