Find Work Item Id Using Custom Attribute
I am working on a project where I need to add an attachment to a work item by the work items id. I can successfully upload the attachments but I have to manually supply the work item id. I want to automate this process.
Using the Java API how do I create a query that takes a custom attribute as the parameter:long customId, and returns an int workItemId?
Code examples appreciated.
Using the Java API how do I create a query that takes a custom attribute as the parameter:long customId, and returns an int workItemId?
Code examples appreciated.
One answer
You can find a work item by ID using
You can access a custom attribute like this:
I have no code for querying at hand, I would suggest to search this forum, there have been a lot of code snippets posted over time.
IWorkItemClient workItemClient = (IWorkItemClient) fTeamRepository.getClientLibrary(IWorkItemClient.class);
IWorkItem linkdest = workItemClient.findWorkItemById(fLinkDestination,IWorkItem.FULL_PROFILE, null);
You can access a custom attribute like this:
IWorkItemClient workItemClient= (IWorkItemClient) fTeamRepository.getClientLibrary(IWorkItemClient.class);
IAttribute customString = workItemClient.findAttribute(fProjectArea,fCustomStringAttributeID, null);
if(null!=customString){
if(workItem.hasCustomAttribute(customString))
String value=workItem.getValue(customString);
}
I have no code for querying at hand, I would suggest to search this forum, there have been a lot of code snippets posted over time.