It's all about the answers!

Ask a question

Expressions - custom attribute


Reverse Reverse (343) | asked Sep 25 '19, 1:54 p.m.
edited Sep 26 '19, 2:15 a.m. by Ralph Schoon (63.1k33646)

 https://rsjazz.wordpress.com/2012/11/19/using-expressions-for-automation/


I want to get all workitems with custom value = 100;
Is it feasible ?
how ?

IAuditableCommon auditableCommon = (IAuditableCommon) teamRepository.getClientLibrary(IAuditableCommon.class);
IQueryableAttribute attribute = QueryableAttributes.getFactory(
    IWorkItem.ITEM_TYPE).findAttribute(projectArea,
    IWorkItem.PROJECT_AREA_PROPERTY, auditableCommon, monitor);
IQueryableAttribute type = QueryableAttributes.getFactory(
    IWorkItem.ITEM_TYPE).findAttribute(projectArea,
    IWorkItem.TYPE_PROPERTY, auditableCommon, monitor);

Expression inProjectArea = new AttributeExpression(attribute, AttributeOperation.EQUALS, projectArea); Expression isType = new AttributeExpression(type, AttributeOperation.EQUALS, workitemTypeID); Term typeinProjectArea= new Term(Term.Operator.AND); typeinProjectArea.add(inProjectArea); typeinProjectArea.add(isType);

</pre>

Accepted answer


permanent link
Ralph Schoon (63.1k33646) | answered Sep 26 '19, 2:17 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Note: this is a RTC question tag rational-team-concert . Jazz Foundation is totally different and few people know what it entails.


As far as I know you substitute the IWorkItem.TYPE_PROPERTY with the custom attribute ID. E.g. "id.of.my.custom.attribute".


 
IQueryableAttribute type = QueryableAttributes.getFactory(
    IWorkItem.ITEM_TYPE).findAttribute(projectArea,
    IWorkItem.TYPE_PROPERTY, auditableCommon, monitor);
E.g.
IQueryableAttribute type = QueryableAttributes.getFactory(
    IWorkItem.ITEM_TYPE).findAttribute(projectArea,
    "id.of.my.custom.attribute", auditableCommon, monitor);

It also helps when knowing how to search for examples in the SDK. See https://rsjazz.wordpress.com/2019/05/16/searching-and-exploring-the-rtc-sdk/

By the way, this is an SDK and the API is an application programming  interface that is used to create the client and the server application. It is not a special API designed to make it easy for users inexperienced with it. It is important to use available resources e.g. being able to search the SDK.  

Reverse Reverse selected this answer as the correct answer

Comments
Reverse Reverse commented Sep 26 '19, 11:28 a.m.

 it worked ..!!! thank you 


The result number are matching ..

how to print & traverse the results ?

IQueryResult<IResolvedResult<IProjectArea>> results .

hasnext fails everytime 

Your answer


Register or 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.