It's all about the answers!

Ask a question

How to get work item type attribute value?


pugazhenthi samidurai (26423942) | asked May 22 '12, 12:46 a.m.
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



permanent link
Ralph Schoon (63.1k33646) | 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.

Your answer


Register or to post 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.