It's all about the answers!

Ask a question

How to get the WorkItems from a Project Area based on their type ?

Sujith Gannamaneni (1637) | asked Aug 22 '14, 2:59 p.m.
edited Aug 22 '14, 3:05 p.m.
I am trying to get all the work items which have their type as defect from a particular project area. But I'm only able to get all the work items irrespective of their type from a particular project area. Can any one please tell me how to add the type criteria and get the work items which are of type defect. Below is the code which I am working on.


String repoUri = "****************";
        final String userId = "****************";
        final String password = "******************";
        List<IWorkItem> defectWorkitems=new ArrayList<IWorkItem>();
        try {
            // Login to the repository using the provided credentials
            ITeamRepository repo = TeamPlatform.getTeamRepositoryService().getTeamRepository(repoUri); repo.registerLoginHandler(new ILoginHandler2() {
                public ILoginInfo2 challenge(ITeamRepository arg0) {
                    return new UsernameAndPasswordLoginInfo(userId, password);
            repo.login(new SysoutProgressMonitor());
            IProcessItemService connect = (IProcessItemService) repo.getClientLibrary(IProcessItemService.class);
            List<IProjectArea> p = connect.findAllProjectAreas(null, new SysoutProgressMonitor());
            System.out.println("Project Areas :");
            for(IProjectArea projectArea: p){
                    IAuditableClient auditableClient = (IAuditableClient) repo.getClientLibrary(IAuditableClient.class);
                    IQueryClient queryClient = (IQueryClient) repo.getClientLibrary(IQueryClient.class);
                    IQueryableAttribute attribute = QueryableAttributes.getFactory(IWorkItem.ITEM_TYPE).findAttribute(projectArea, IWorkItem.PROJECT_AREA_PROPERTY, auditableClient, null);
                    Expression expression = new AttributeExpression(attribute, AttributeOperation.EQUALS, projectArea);
                    IQueryResult<IResolvedResult<IWorkItem>> results = queryClient.getResolvedExpressionResults(projectArea, expression, IWorkItem.FULL_PROFILE);
                    while(results.hasNext(new SysoutProgressMonitor())){
                        IResolvedResult<IWorkItem> result = SysoutProgressMonitor());
                        IWorkItem workItem = (IWorkItem) result.getItem();
}             System.out.println(defectWorkitems.size());
     } finally {

One answer

permanent link
sam detweiler (12.5k6195201) | answered Aug 22 '14, 5:06 p.m.
see Ralphs blog on  querys

Sujith Gannamaneni commented Aug 23 '14, 9:43 p.m.

I m getting an error while running the above code right after printing the Project Area list.

ERROR: - Value set provider not found:

sam detweiler commented Aug 24 '14, 6:30 a.m.

Hm.. I have not figured out how to configure a batch application using the plain java apis to support running scripted extensions.

Your answer

Register or to post 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.