Querying RTC workitem based on the value of a custom attribute
![]()
Kanagaraj Duraisamy (1●5●7)
| asked Jul 29 '13, 1:01 p.m.
edited Jul 29 '13, 1:34 p.m. by Ralph Schoon (62.3k●3●36●43)
I have created a custom attribute in RTC. I would like to query the work item using plain java api based on the custom attribute's value.
I used the below code but it is bringing the work item presented in the different project area as well. But, i need the work item presented only in the project which i am passing.
String projectName = "XYZ";
IProjectArea projectArea = getProjectArea(projectName, repo);
IQueryClient queryClient = workItemService.getQueryClient();
IAuditableClient auditableClient = (IAuditableClient)repo.getClientLibrary(IAuditableClient.class);
IQueryableAttribute attribute=QueryableAttributes.getFactory(IWorkItem.ITEM_TYPE).findAttribute(projectArea, propertyName, auditableClient, monitor);
Expression inProjectArea= new AttributeExpression(attribute,AttributeOperation.EQUALS, targetId);
IQueryResult<IResolvedResult<IWorkItem>> results=queryClient.getResolvedExpressionResults(projectArea, inProjectArea,IWorkItem.SMALL_PROFILE);
results.setLimit(Integer.MAX_VALUE);
while (results.hasNext(monitor))
{
IResolvedResult<IWorkItem> resresult = (IResolvedResult<IWorkItem>) results.next(monitor);
item = resresult.getItem();
}
Your help is highly appreciated.
Regards,
Kanagaraj
|
3 answers
![]()
Ralph Schoon (62.3k●3●36●43)
| answered Jul 29 '13, 1:43 p.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
I would suggest looking into providing the attribute ID of the custom attribute in a findAttribute and follow the rest of the pattern.
Comments Ralph,
|
Comments
Kanagaraj,
Were you ever able to get this to work? I have never been able to JAZZ query to obtain a specific value for a custom attribute..
I see responses from Ralph in the post but I don`t think that works either ,
At least I have not been able to get it work,
Please pass your example if it is working for you.