Find a work item by attribute through java api
I want to create an operation advisor to add a link between the current work item and some other work item.
I need to query RTC to find the other work item (thus get its IWorkItem instance). How can I do this?
The query must be by the work item type and an attribute.
Thanks for the help.
Accepted answer
https://jazz.net/forum/questions/161814/search-workitems-based-on-the-value-of-the-custom-attribute
and this answer
and Ralph's blog
https://rsjazz.wordpress.com/2012/10/29/using-work-item-queris-for-automation/
these are client side examples, but not too much different on the server side
Comments
Sam, thanks for the answer. It has been very helpful.
Do you know how can I retrieve an instance of IQueryCommon on the server side?
It seems to be necessary to execute the query. Or do you know if there is another way?
private static IQueryService fQueryService = null;
fQueryService = getService(IQueryService.class);
how I use it
the query is the expression and and/or terms.
IQueryPage qpage = fQueryService.queryItems(query, new IProjectAreaHandle[] { ProjectAreaHandle }, IQueryService.ITEM_QUERY_MAX_PAGE_SIZE);
also need to add the service to the plugin required service list in the plugin.xml
Thanks again, Sam
I ended up using getService(IQueryCommon.class) to retrieve an IQueryCommon instance and added it to plugin.xml as a required service.