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

How to query a work item based on a custom attribute?

How to query a work item based on a custom attribute? I'm trying the following code, but always getting null for queryableCustom in the code below.

IAuditableClient auditableClient = (IAuditableClient) teamRepository

.getClientLibrary(IAuditableClient.class);
IQueryableAttribute queryableCustom = QueryableAttributes.getFactory(IWorkItem.ITEM_TYPE)
.findAttribute(processArea, "cmvc_name", auditableClient, monitor);
System.out.println("queryableCustom="+queryableCustom);
Expression attributeExpression = new AttributeExpression(queryableCustom,
AttributeOperation.EQUALS, defectName);
System.out.println("attributeExpression="+attributeExpression);
IQueryClient queryClient = (IQueryClient) teamRepository
.getClientLibrary(IQueryClient.class);
IQueryResult<IResolvedResult<IWorkItem>> result = queryClient.getResolvedExpressionResults(
processArea, attributeExpression, IWorkItem.FULL_PROFILE);
if (result.hasNext(monitor)) {
IResolvedResult<IWorkItem> resolved = result.next(monitor);
System.out.println("Name="+resolved.getItem().getHTMLSummary());
return resolved.getItem();
}

1

1 vote



2 answers

Permanent link
How to query a work item based on a custom attribute? I'm trying the following code, but always getting null for queryableCustom in the code below.

IAuditableClient auditableClient = (IAuditableClient) teamRepository

.getClientLibrary(IAuditableClient.class);
IQueryableAttribute queryableCustom = QueryableAttributes.getFactory(IWorkItem.ITEM_TYPE)
.findAttribute(processArea, "cmvc_name", auditableClient, monitor);
System.out.println("queryableCustom="+queryableCustom);
Expression attributeExpression = new AttributeExpression(queryableCustom,
AttributeOperation.EQUALS, defectName);
System.out.println("attributeExpression="+attributeExpression);
IQueryClient queryClient = (IQueryClient) teamRepository
.getClientLibrary(IQueryClient.class);
IQueryResult<IResolvedResult<IWorkItem>> result = queryClient.getResolvedExpressionResults(
processArea, attributeExpression, IWorkItem.FULL_PROFILE);
if (result.hasNext(monitor)) {
IResolvedResult<IWorkItem> resolved = result.next(monitor);
System.out.println("Name="+resolved.getItem().getHTMLSummary());
return resolved.getItem();
}


I was able to resolve this problem. The above code works fine, the problem was that I was using wrong project area which did not have that custom attribute.

0 votes


Permanent link
 How about the customization attribute, if the attribute type is "Enumeration List"?

0 votes

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

Question asked: May 10 '10, 1:42 p.m.

Question was seen: 5,450 times

Last updated: Jan 22 '15, 3:12 a.m.

Confirmation Cancel Confirm