It's all about the answers!

Ask a question

java api - how to find a work item using a custom attribute


Reverse Reverse (342) | asked Sep 24 '19, 12:25 p.m.
edited Sep 25 '19, 5:45 a.m. by Ralph Schoon (59.7k23643)

 java api - rather than using int id ..how to find a work item using a custom attribute?

Please guide. 


Comments
Ralph Schoon commented Sep 25 '19, 5:44 a.m. | edited Sep 25 '19, 5:45 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Please tag your questions with a product name. I don't want to have to fix all your questions.

Accepted answer


permanent link
Ralph Schoon (59.7k23643) | answered Sep 25 '19, 5:41 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

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

This allows to basically create an expression that acts as a work item query. It is possible to define conditions, including for custom attributes.

Reverse Reverse selected this answer as the correct answer

Comments
Reverse Reverse commented Sep 25 '19, 10:32 a.m.

  I have to say - this is the most horrible piece of API ever written..

A simple task can take hours.

I have a saved query but through API i cant pass the parameter.
Then found out about creating on-the-fly queries with expression.

 I have is a custom attribute [custom] ..
All I need is give me all work items having [custom =1]

THIS API SUCKS 


Reverse Reverse commented Sep 25 '19, 10:33 a.m.
 IQueryableAttribute attribute = QueryableAttributes.getFactory(IWorkItem.ITEM_TYPE).findAttribute(currProject, IWorkItem.PROJECT_AREA_PROPERTY, auditableClient, null);

how can i use custom attribute here ?


Ralph Schoon commented Sep 26 '19, 2:10 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

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.  

Your answer


Register or to post your answer.