Retrieving custom attribute values of a work item
Can some one let me know how to get the custom attribute values?
I'm doing this List<IAttributeHandle> attrHandles= workItem.getCustomAttributes(); int size = attrHandles.size(); for(int i=0; i<size;i++) { IAttributeHandle handle= attrHandles.get(i); IItem attrItem = repositoryItemService.fetchItem(handle, null); IAttribute attribute = (IAttribute) attrItem; System.out.println(attribute.getAttributeType()); System.out.println(attribute.getIdentifier()); Object value= workItem.getValue(attribute); System.out.println("value"+ value); } Output is size is2 Category skill valuecom.ibm.team.workitem.common.model.ILiteral:Category.literal.l1 Role Role valuecom.ibm.team.workitem.common.model.ILiteral:Role.literal.l1 As you see from the output. workItem.getValue(attr) does not return the actual value stored for that attribute.Custom attributes here are enumerations. Any thing specific to be done to get the attr values in this context? |
3 answers
Hi
workItem.getValue returns the value that is stored on the work item (the id of a literal). To get a nice presentation of that (icon, display name), you have to resolve the according enumeration. Have a look at IWorkItemCommon#resolveEnumeration where you pass in the the attribute handle and get an IEnueration from where you can get the Literal by using findEnumerationLiteral and on the Literal, you have getName and getIconURL. Regards Marcel Jazz Work Item team |
Hi..
I have similar problem about the custom attribue. But my environment is in java client. I found I have no repositoryItemService. My codes like follows: IWorkItem workItem= workItemClient.findWorkItemById(9,IWorkItem.FULL_PROFILE, new NullProgressMonitor()); List<IAttributeHandle> lst = workItem.getCustomAttributes(); for(IAttributeHandle ih:lst){ ..how can I get IAttribute from IAttributeHandle? } please kinldy give me a help. Thanks in advance. Best Regards |
IWorkItem workItem= You can use IAttribute attribute= workItemClient.getAuditableCommon().resolveAuditable(ih, IAttribute.FULL_PROFILE, monitor); -- Regards, Patrick Jazz Work Item Team |
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.