getting value of custom attribute programmatically
Hi All,
I have added a custom attribute to the work item UI(defect). I am trying to programmatically retrieve the value of the custom attribute selected by the user. The custom attribute is a drop down menu populated with certain defined enumeration.
Could anyone please guide me on how to retrieve this value?
Thanks,
Ananya
I have added a custom attribute to the work item UI(defect). I am trying to programmatically retrieve the value of the custom attribute selected by the user. The custom attribute is a drop down menu populated with certain defined enumeration.
Could anyone please guide me on how to retrieve this value?
Thanks,
Ananya
3 answers
Please see this post: https://rsjazz.wordpress.com/2013/01/02/working-with-work-item-attributes/
You first find the IAttribute using the ID and then you getValue the value.
It is irrelevant if the values are in a drop down list. That is just a presentation. In the API you typically just get the value from the work item.
Thank you both for replying.
Ralph,
I checked the blog. I was trying to get the value of iAttribute in the following.
Since AttributeImpl implements IAttribute, I tried using methods defined in the class, but since its constructor is protected I couldn't use it to get the value. Is there any other way round, I can retrieve iAttribute?
Thanks,
Ananya
Ralph,
I checked the blog. I was trying to get the value of iAttribute in the following.
if (workItem.hasAttribute(iAttribute)) {
Object value = workItem.getValue(iAttribute);
}
Since AttributeImpl implements IAttribute, I tried using methods defined in the class, but since its constructor is protected I couldn't use it to get the value. Is there any other way round, I can retrieve iAttribute?
Thanks,
Ananya
Comments
Almost the first code in the post https://rsjazz.wordpress.com/2013/01/02/working-with-work-item-attributes/ talks about findAttribute() .
IWorkItemClient workItemClient = (IWorkItemClient) teamRepository.getClientLibrary(IWorkItemClient.class); IAttribute someAttribute= workItemClient.findAttribute(fProjectArea, "some_attribute_ID", monitor);
So you use the ClientLibary or the Service to find the attribute. The server API, if you are in a participant or advisor is described here: https://rsjazz.wordpress.com/2012/07/31/rtc-update-parent-duration-estimation-and-effort-participant/