It's all about the answers!

Ask a question

Find a work item by attribute through java api


Thiago Barreto (103) | asked Sep 01 '14, 9:59 a.m.
Hello,

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


permanent link
sam detweiler (12.5k6186201) | answered Sep 01 '14, 10:28 a.m.
edited Sep 01 '14, 10:29 a.m.
see this topic
https://jazz.net/forum/questions/161814/search-workitems-based-on-the-value-of-the-custom-attribute
and this answer 
Sujith Gannamaneni (164) | answered Aug 27, 11:03 a.m.

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
Thiago Barreto selected this answer as the correct answer

Comments
Thiago Barreto commented Sep 02 '14, 9:46 a.m.

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?


sam detweiler commented Sep 02 '14, 9:58 a.m.

    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
         


Thiago Barreto commented Sep 02 '14, 3:00 p.m.

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.


Your answer


Register or to post your answer.