It's all about the answers!

Ask a question

How to search Work items which have certain "Approval type" AND that Approval type has certain "Approval status"

Yasuyuki Tominaga (297416) | asked Feb 23 '16, 11:46 p.m.
I want to search Work items which have certain "Approval type" AND that Approval type has certain "Approval status".
But that can't be possible by normal Work Item query.
I know there is an enhancement request "Enhancement 274343: Problem with query logic for approvals"
Can I make such a query using RTC Java SDK?

Accepted answer

permanent link
Kohji Ohsawa (5951310) | answered Feb 23 '16, 11:49 p.m.

It can be done by writing a custom Jazz client program like below. Hoping it would help you.

private static void run(ITeamRepository repository) throws TeamRepositoryException {
        IItemManager itemManager = repository.itemManager();
        IProcessItemService processItemService = (IProcessItemService)repository.getClientLibrary(IProcessItemService.class);
        List<IProjectArea> projectArea = processItemService.findAllProjectAreas(null, null);
        Iterator<IProjectArea> iter = projectArea.iterator();
            IProjectArea area = (IProjectArea);
            IWorkItemClient workItemClient = (IWorkItemClient)repository.getClientLibrary(IWorkItemClient.class);           
            IQueryClient queryClient = workItemClient.getQueryClient();
            IAuditableClient auditableClient = (IAuditableClient)repository.getClientLibrary(IAuditableClient.class);
            IQueryableAttribute attribute = QueryableAttributes.getFactory(IWorkItem.ITEM_TYPE).findAttribute(area, IWorkItem.STATE_PROPERTY, auditableClient, null);
            Expression expression = new AttributeExpression(attribute, AttributeOperation.NOT_EQUALS, "1");
            IQueryResult<IResolvedResult<IWorkItem>> results = queryClient.getResolvedExpressionResults(area, expression, IWorkItem.FULL_PROFILE);
            List<IResolvedResult<IWorkItem>> page =  results.nextPage(null);
            Iterator<IResolvedResult<IWorkItem>> iterResult = page.iterator();
                IResolvedResult<IWorkItem> resolvedResult =;
                IWorkItem workItem = resolvedResult.getItem();
                IApprovals approvals = workItem.getApprovals();
                List<IApproval> approvalList = approvals.getContents();
                Iterator<IApproval> approvalListIter = approvalList.iterator();
                    IApproval approval =;
                    IContributor contributor = (IContributor)itemManager.fetchCompleteItem(approval.getApprover(), ItemManager.DEFAULT, null);
                    System.out.println("Approver: " + contributor.getName());
                    System.out.println("Name: " + approval.getDescriptor().getDueDate());
                    System.out.println("Type: " + approval.getDescriptor().getTypeIdentifier());
                    System.out.println("Due Date:" + approval.getDescriptor().getDueDate());
Yasuyuki Tominaga selected this answer as the correct answer

Your answer

Register or to post your answer.