Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

Querying Work Items by their planned for / target (RTC Java API)

 Hi, 

I am trying to query work items that have a specific planned for / target but keep getting errors. I have tried the expression with both the name of the IIteration and the object itself (it's current state). Any help is much appreciated!

Here is my error currently:
com.ibm.team.repository.common.transport.ServiceMethodInvocationError: com.ibm.team.repository.common.query.QueryException: Unknown queryable field: target

and my code:
     IWorkItemClient workItemClient = (IWorkItemClient) getTeamRepository().getClientLibrary(IWorkItemClient.class);
   

    //Create a query factory
        IQueryableAttributeFactory factory = QueryableAttributes.getFactory(IWorkItem.ITEM_TYPE);
        
        IQueryableAttribute typeAttribute = factory.findAttribute(getProjectArea(), IWorkItem.TARGET_PROPERTY, getAuditableClient(), getMonitor());
        
        //Begin writing our query expression
        AttributeExpression typeExpression = new AttributeExpression(typeAttribute, AttributeOperation.CONTAINS, versions.get(14));
         
        
        Term term= new Term(Operator.AND);
        term.add(typeExpression);

        //Execute query
        IQueryClient queryClient = (IQueryClient) getTeamRepository().getClientLibrary(IQueryClient.class);
        IQueryResult<IResolvedResult<IWorkItem>> result = queryClient.getResolvedExpressionResults(getProjectArea(), term, IWorkItem.FULL_PROFILE);
   

0 votes

Comments

did u try the iteration id (the string behind the label) 

like so?


 AttributeExpression typeExpression = new AttributeExpression(typeAttribute, AttributeOperation.CONTAINS, versions.get(14).getLabel());

I have and I get this error:

java.lang.IllegalArgumentException: Argument must be an instance of IAuditableHandle 

 HI White,

           I am also trying to fetch the work items based on the current sprint,
I am also getting java.lang.IllegalArgumentException: Argument must be an instance of IAuditableHandle .
below is my code,
IWorkItemClient workItemClient = (IWorkItemClient) iTeamRepository.getClientLibrary(IWorkItemClient.class);
IAuditableCommon iAuditableCommon = (IAuditableCommon) iTeamRepository.getClientLibrary(IAuditableCommon.class);

IQueryableAttribute planAttribute = factory.findAttribute(projectArea, IWorkItem.TARGET_PROPERTY, iAuditableCommon, monitor);
Expression plan = new AttributeExpression(planAttribute, AttributeOperation.EQUALS, CurrentMilestoneVariable.VARIABLE_ID);
Term term = new Term(Term.Operator.AND);
term.add(plan);
IQueryDescriptor iQueryDescriptor = queryClient.createQuery(projectArea, QueryTypes.WORK_ITEM_QUERY, "AllItems", term); --- getting exception at this line.
Please provide the solution if you did that.

regards, ramesh


Hi Ramesh M,

I am also doing the same, trying to query work items that have a specific planned for.
Can you please share your solution if you have it already.


Thank you.

Regards,
Navin


Be the first one to answer this question!

Register or log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,938
× 411

Question asked: Mar 06 '14, 10:26 a.m.

Question was seen: 5,562 times

Last updated: Aug 22 '17, 5:50 p.m.

Confirmation Cancel Confirm