workItem.hasAttribute(customAttribute) returning false, even though the work item contains the attribute?
![]()
I am attempting to retrieve a custom attribute from a work item using the Plain Java API. Other custom attributes to our project area are being picked up, however this one is not.
IWorkItemClient wiClient = (IWorkItemClient) teamRepo.getClientLibrary(IWorkItemClient.class); IWorkItem sample = wiClient.findWorkItemById(workItemNumber, IWorkItem.FULL_PROFILE, null); List<com.ibm.team.workitem.common.model.IAttribute> projectAreaAttributeList = wiClient.findAttributes(projectArea, new NullProgressMonitor()); } else { log("Work item does not have attribute: "+ attribute.getDisplayName()); }} In the above example I am retrieving all the attributes for our project area. The attribute I am trying to retrieve is in this list, as it's display name is logged from the "log(attribute.getDisplayName())" call. However, it is then logged that the work item doesn't have the custom attribute. When I navigate to the work item through RTC, I can see the attribute and it is populated, however the call to "sample.hasAttribute(attribute)" still returns false in this case. Other custom attributes are retrieved and displayed correctly.
It's worth noting that this attribute is added to the work item upon completion, and isn't present in the work item from the very start of it's lifetime like the other custom attributes. I was wondering if this may be something to do with the problem.
Any help would be greatly appreciated, thank you!
|
One answer
![]()
Ralph Schoon (63.3k●3●36●46)
| answered Mar 06 '19, 6:04 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER edited Mar 06 '19, 6:07 a.m. This does not make sense:
A work item has the attribute or it does not. That the value is not set should have no impact on the "hasAttribute".
Old work items that were created before the attribute was defined do not have the attribute. Synchronize the attributes in this case. There is a API call addAttribute() that can add an existing attribute that is not available.
Use the ID to understand which attribute you are talking about. The display Name does not need to be unique.
|
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.