How to fetch WorkItems based on "Found In" (release) value?
The below code didn't work for me. Please let me know what variable that need to pass to expression to get value found in? how it can be done?
WorkItemTypeVariable variable = new WorkItemTypeVariable("Release1");
IQueryableAttribute foundInAttribute = QueryableAttributes.getFactory(IWorkItem.ITEM_TYPE).findAttribute(projectArea, IWorkItem.FOUND_IN_PROPERTY, auditableClient, monitor);
Expression foundInExpression = new AttributeExpression(foundInAttribute, AttributeOperation.EQUALS, variable);
Term term = new Term(Operator.AND);
term.add(foundInExpression);
com.ibm.team.workitem.common.query.IQueryResult<IResolvedResult<IWorkItem>> results = queryClient.getResolvedExpressionResults(projectArea, term, IWorkItem.FULL_PROFILE);
WorkItemTypeVariable variable = new WorkItemTypeVariable("Release1");
IQueryableAttribute foundInAttribute = QueryableAttributes.getFactory(IWorkItem.ITEM_TYPE).findAttribute(projectArea, IWorkItem.FOUND_IN_PROPERTY, auditableClient, monitor);
Expression foundInExpression = new AttributeExpression(foundInAttribute, AttributeOperation.EQUALS, variable);
Term term = new Term(Operator.AND);
term.add(foundInExpression);
com.ibm.team.workitem.common.query.IQueryResult<IResolvedResult<IWorkItem>> results = queryClient.getResolvedExpressionResults(projectArea, term, IWorkItem.FULL_PROFILE);
Accepted answer
As stated in the answer to your question https://jazz.net/forum/questions/206015/how-to-get-the-workitems-based-on-filed-against-value you can't just put in a string. You have to find the object using the string from all the existing releases and pass the object or handle.
This is, of course, true for all attribute types that are not strings.
This is, of course, true for all attribute types that are not strings.
Comments
From my latest version of https://rsjazz.wordpress.com/2015/02/09/a-rtc-workitem-command-line-version-2/
/* * Find a deliverable (release) object from its name Deliverables don't have * ID's, so you can only search for the value. * * @param value * - the name of the deliverable * @return the deliverable object * @throws TeamRepositoryException / private IDeliverable findDeliverable(String value) throws TeamRepositoryException { return getWorkItemCommon().findDeliverableByName( getWorkItem().getProjectArea(), value, IDeliverable.FULL_PROFILE, monitor); }