How get "Found In" attribute with RTC SDK?
Hello!
We develop a follow-up action trigger which gets the attributes (names and values) from workitems which are changed. We can get almost any attributes for an RTC workitem. But we can not find "Found In" attribute (or release number) which is defined in releases list of a project area.
Can anybody recommend us how we can get this value from IWorkItem or another way?
The environment is Jazz CLM v4.0.5.
Thank you in advance!
We develop a follow-up action trigger which gets the attributes (names and values) from workitems which are changed. We can get almost any attributes for an RTC workitem. But we can not find "Found In" attribute (or release number) which is defined in releases list of a project area.
Can anybody recommend us how we can get this value from IWorkItem or another way?
The environment is Jazz CLM v4.0.5.
Thank you in advance!
Accepted answer
Simply use
IWorkItemClient workItemClient = ((IWorkItemClient) teamRepository.getClientLibrary(IWorkItemClient.class));
IAttribute attribute = workItemClient.findAttribute(projectArea, attributeId, null);
To find out the attributeId do the following:
- Open the project area in the eclipse client
- Choose 'Process Configuration' tab
- Navigate to Project Configuration -> Configuration Data -> Work Items -> Types and Attributes
- click a built-in attribute and choose Edit
- instead of the whole ID path (like 'com.ibm.team.workitem.attribute.modified'), only use the last part ('modified').
---> for custom attributes, you have to use the whole path (like in the source code above)
(a part of this answer is from my answer on this topic)
Comments
Hi Lucas,
I was having a suspicion that I need to go this way but I stopped my investigation too earlier!
Thank you very much! I'm sure this topic will be helpful for other who goes this way.
The advantage if this code is that it is generic for built in and custom attributes, that's why I prefer it over the approach Susan Hanson suggests below.
One other answer
I don't actually read it, but I do set it using this logic:
IAttribute foundInAttr = myRepo.findAttribute(IWorkItem.FOUND_IN_PROPERTY);
IDeliverable del = myRepo.workItemClient.findDeliverableByName(myRepo.projectArea, name, IDeliverable.DEFAULT_PROFILE, myRepo.monitor);
newWorkItem.setValue(foundInAttr, deliverable.getItemHandle());
I would assume once you have the foundInAttr, you could do something like
IDeliverable del = (IDeliverable) oldWorkItem.getValue(foundInAttr);
IAttribute foundInAttr = myRepo.findAttribute(IWorkItem.FOUND_IN_PROPERTY);
IDeliverable del = myRepo.workItemClient.findDeliverableByName(myRepo.projectArea, name, IDeliverable.DEFAULT_PROFILE, myRepo.monitor);
newWorkItem.setValue(foundInAttr, deliverable.getItemHandle());
I would assume once you have the foundInAttr, you could do something like
IDeliverable del = (IDeliverable) oldWorkItem.getValue(foundInAttr);