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

How to get the WorkItems based on "Filed Against" value?

We want to fetch the WorkItems based on specific "Field Against" value set. The below code didn't work for me and gives the error. Can you please let us know what could be wrong? Thanks in advance

I didnt find IWorkItem.FILED_AGAINST_PROPERTY hence i used CATEGORY_PROPERTY and TestProj/UI1 is the filed against value that set.
-----------
IQueryableAttribute filedAgainstAttribute = QueryableAttributes.getFactory(IWorkItem.ITEM_TYPE).findAttribute(projectArea, IWorkItem.CATEGORY_PROPERTY, auditableClient, monitor);
            AttributeExpression filedAgainstExpression = new AttributeExpression(filedAgainstAttribute, AttributeOperation.EQUALS, XMLString.createFromPlainText("TestProj/UI1"));
IQueryResult<IResolvedResult<IWorkItem>> results = queryClient.getResolvedExpressionResults(projectArea, filedAgainstExpression, IWorkItem.FULL_PROFILE);
------------------------------------
It gives below error at last line in the above code snippet.
java.lang.IllegalArgumentException: Argument must be an instance of IAuditableHandle
    at com.ibm.team.workitem.common.internal.model.SetAttributeType.toString(SetAttributeType.java:73)
    at com.ibm.team.workitem.common.internal.expression.AttributeValueFactory$ConstantValue.saveState(AttributeValueFactory.java:58)
    at com.ibm.team.workitem.common.expression.AttributeExpression.saveValueProxy(AttributeExpression.java:175)
    at com.ibm.team.workitem.common.expression.AttributeExpression.saveState(AttributeExpression.java:165)
    at com.ibm.team.workitem.common.expression.Term.saveState(Term.java:209)
    at com.ibm.team.workitem.common.internal.expression.XMLExpressionSerializer.serialize(XMLExpressionSerializer.java:137)

0 votes


Accepted answer

Permanent link
You can't just put a string in there, I think. You have to find the category object from the string and then put in the ICategory object.
Sridhar Kuna selected this answer as the correct answer

0 votes

Comments

Thanks Ralph. I am able to figure it out with category list. The below code snippet would be helpful for others who are on same page.
private static String CATEGORY_NAME = "UI1";
List<ICategory> findCategories = workItemCommon.findCategories(projectArea, ICategory.FULL_PROFILE, monitor);
    for(ICategory category : findCategories) {
          if(category.getName().contains(CATEGORY_NAME)){
              filedAgainstAttribute = QueryableAttributes.getFactory(IWorkItem.ITEM_TYPE).findAttribute(projectArea, IWorkItem.CATEGORY_PROPERTY, auditableClient, monitor);
                    filedAgainstExpression = new AttributeExpression(filedAgainstAttribute, AttributeOperation.EQUALS, category);
       }
  }

Your answer

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
× 169

Question asked: Sep 03 '15, 11:06 a.m.

Question was seen: 3,168 times

Last updated: Sep 14 '15, 5:38 a.m.

Confirmation Cancel Confirm