Find custom attribute value from a IWorkItem using Plain Java Api
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
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.
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.