How to get work item type attribute value?
![]()
Hi,
I am using the below function to retrieve work item type attribute value. But it doen't return any value. public static String getWorkitemTypeFieldValue(IWorkItem workItem,String fCustomStringAttributeID) { ITeamRepository repository = RepositoryManager.getInstance().getCurrentRepository(); IWorkItemClient workItemClient = (IWorkItemClient) repository.getClientLibrary(IWorkItemClient.class); IAuditableCommon iac = workItemClient.getAuditableCommon(); IProgressMonitor monitor = new NullProgressMonitor(); IProjectArea projectArea = null; try { projectArea = getReportOneProjectArea(); } catch (TeamRepositoryException e2) { e2.printStackTrace(); } IAttribute customString = null; try { customString = workItemClient.findAttribute(projectArea, fCustomStringAttributeID, null); } catch (TeamRepositoryException e) { e.printStackTrace(); } Object value = workItem.getValue(customString); String sValue = ""; if(value!=null && value instanceof String) { sValue = (String) value; System.out.print("\tValue: " + sValue); } System.out.println(); return sValue; } Let me know is there any other way to get the value of work item type attribute. |
One answer
![]()
Ralph Schoon (61.8k●3●36●43)
| answered May 22 '12, 2:06 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Your code looks OK to me.
You should check if the work item actually has the custom attribute and a value for it. See: https://jazz.net/forums/viewtopic.php?p=79043 https://jazz.net/forums/viewtopic.php?p=68390 You might have to run "synchronize attributes" to make sure all work items have the attribute. The other area to look at is the load profile for resolving/loading he work item. Not sure if you would get a value if you load with the SMALL_PROFILE. |