It's all about the answers!

Ask a question

getting value of custom attribute programmatically


Ananya Joisa (4552124) | asked Feb 19 '13, 2:15 p.m.
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

3 answers



permanent link
Ralph Schoon (62.3k33643) | answered Feb 19 '13, 2:26 p.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
 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.

permanent link
Eric Jodet (6.3k5111120) | answered Feb 20 '13, 1:02 a.m.
JAZZ DEVELOPER
Hello,
you may also want to read https://jazz.net/wiki/bin/view/Main/AttributeCustomization#Calculated_values

Thanks.
Eric.

permanent link
Ananya Joisa (4552124) | answered Feb 26 '13, 5:50 a.m.
Thank you both for replying.

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
Ralph Schoon commented Feb 26 '13, 6:04 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

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/ 

Your answer


Register or to post your answer.