It's all about the answers!

Ask a question

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


1
1
Vinod Kumar (9612010) | asked May 10 '10, 1:42 p.m.
JAZZ DEVELOPER
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();
}

2 answers



permanent link
Vinod Kumar (9612010) | answered May 17 '10, 10:26 p.m.
JAZZ DEVELOPER
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.

permanent link
Albert Yao (521917) | answered Jan 22 '15, 3:10 a.m.
edited Jan 22 '15, 3:12 a.m.
 How about the customization attribute, if the attribute type is "Enumeration List"?

Your answer


Register or to post your answer.