It's all about the answers!

Ask a question

Find Work Item Id Using Custom Attribute


Josh Bambrick (21135) | asked May 22 '12, 8:50 p.m.
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.

One answer



permanent link
Ralph Schoon (63.3k33646) | answered May 23 '12, 2:19 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
You can find a work item by ID using

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.

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.