Query RTC work items with a certain tag programmatically
I am trying to create and run a query in order to find all work items in a specific project area that has a specific tag.
For that I am using the following code: ITeamRepository repo = (ITeamRepository) prjArea.getOrigin(); IAuditableCommon auditableCommon = (IAuditableCommon) repo.getClientLibrary(IAuditableCommon.class); IQueryableAttributeFactory factory = QueryableAttributes.getFactory(IWorkItem.ITEM_TYPE); IQueryableAttribute attributeTags = factory.findAttribute(prjArea, IWorkItem.TAGS_PROPERTY, auditableCommon, monitor); Expression hasTag = new AttributeExpression(attributeTags, AttributeOperation.CONTAINS, TAG_NAME); Term term = new Term(Operator.AND); term.add(hasTag); IQueryClient queryClient = (IQueryClient) repo.getClientLibrary(IQueryClient.class); IQueryResult<IResolvedResult<IWorkItem>> queryResult = queryClient.getResolvedExpressionResults(prjArea, term, IWorkItem.FULL_PROFILE); List<IWorkItem> workItems = new ArrayList<IWorkItem>(queryResult.getResultSize(monitor).getTotalAvailable()); The resulting list is empty although it should return one work item. (I tested with a manually created query). What am I missing here? Thank you |
One answer
I missed that part of code.
while (queryResult.hasNext(monitor)) { if (monitor.isCanceled()) { return null; } IResolvedResult<IWorkItem> resolvedResult = queryResult.next(monitor); IWorkItem workItem = resolvedResult.getItem(); workItems.add(workItem); } |
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.