Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

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.

0 votes



One answer

Permanent link
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.

0 votes

Your answer

Register or log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,938

Question asked: May 22 '12, 8:50 p.m.

Question was seen: 4,379 times

Last updated: May 22 '12, 8:50 p.m.

Confirmation Cancel Confirm