How to query work item by status and change wi status programmatically?
Jia Jia Li (805●8●157●192)
| asked Aug 13 '12, 12:43 p.m.
retagged Apr 18 '13, 12:03 p.m. by Morten Madsen (305●32●50)
Hi,
I have two requirement needed to be implement by Plain Java
1. Query the work item by status=resolved
2. Change the work item status to closed by action
Do you know how to do this?
I know the SDK2.0 wiki for create workitem, but do not know how to change status by action and query API.
Thanks very much! |
2 answers
Ralph Schoon (63.5k●3●36●46)
| answered Aug 13 '12, 4:35 p.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Jia,
you can use pre built queries and you can create queries. i believe Robin has some code to get you started here: http://ryehle.wordpress.com/2012/06/28/custom-build-result-pruner/ See Sam's answer https://jazz.net/forum/questions/84612/workitem-state-change-programatically?page=1&focusedAnswerId=84627#84627 for the state change. You can also search the SDK for examples. I found the code there. |
Ralph Schoon (63.5k●3●36●46)
| answered Aug 13 '12, 4:55 p.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
I have used this kind of code to query:
IWorkItemClient workItemService = (IWorkItemClient) targetRepository .getClientLibrary(IWorkItemClient.class); IQueryClient queryClient = workItemService.getQueryClient(); IAuditableClient auditableClient = (IAuditableClient)targetRepository.getClientLibrary(IAuditableClient.class); IQueryableAttribute attribute=QueryableAttributes.getFactory(IWorkItem.ITEM_TYPE).findAttribute(targetProjectArea, IWorkItem.PROJECT_AREA_PROPERTY, auditableClient, monitor); Expression inProjectArea= new AttributeExpression(attribute,AttributeOperation.EQUALS, targetProjectArea); IQueryResult<IResolvedResult<IWorkItem>> results=queryClient.getResolvedExpressionResults(targetProjectArea, inProjectArea,IWorkItem.SMALL_PROFILE); results.setLimit(Integer.MAX_VALUE); while (results.hasNext(monitor)) { IResolvedResult<IWorkItem> resresult = (IResolvedResult<IWorkItem>) results.next(monitor); IWorkItem item = resresult.getItem(); Not sure if there is a clause for querying a state group or state, I guess there is. |
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.