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 (62.3k33643) | answered Dec 09 '13, 10:50 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Minghua,

please start here: https://rsjazz.wordpress.com/2013/02/28/setting-up-rational-team-concert-for-api-development/ and here https://rsjazz.wordpress.com/2013/03/20/understanding-and-using-the-rtc-java-client-api/

Your question should be answered in the second link above and in https://rsjazz.wordpress.com/2013/01/02/working-with-work-item-attributes/ 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.