It's all about the answers!

Ask a question

Find custom attribute value from a IWorkItem using Plain Java Api


Sean Hannon (17146) | asked Jan 10 '13, 5:16 a.m.
  I amen't sure how to do this but my method takes in an IWorkItem and gets List of IAttributeHandles these are used to get the display names (as I only need certain custom attributes). This is what I've got so far and ament sure how to get the values.

private static void findCustomAttributes(IWorkItem iWorkItem) throws TeamRepositoryException 
{
// TODO Auto-generated method stub
List<IAttributeHandle> test = iWorkItem.getCustomAttributes();
test = iWorkItem.getCustomAttributes();
String displayName = null;
Object value = null;

for(int h = 0; h <test.size(); h++)
{
testing = (IAttribute)repo.itemManager().fetchCompleteItem(test.get(h), 0, null);

displayName = testing.getDisplayName();
if(displayName.equals("Closed Date"))
{
value = iWorkItem.getValue(testing);
if(value == null)
{
//Do Something
}
else
{
//Do something else
}
}
}
}

I'm going keep hacking away at it but any help would be much appreciated
Thanks

One answer



permanent link
Ralph Schoon (63.1k33645) | answered Jan 10 '13, 5:40 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
edited Jan 10 '13, 5:40 a.m.
Hi,

in my experience it is a bad idea to match the display name. Use the ID instead, since that is unique. Otherwise you might get a wrong attribute and be puzzled. See http://rsjazz.wordpress.com/2013/01/02/working-with-work-item-attributes/ for more information about this topic. The blog contains several more posts you might be interested in too.

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.