It's all about the answers!

Ask a question

Queries in RTC


Arshad Adavani (231220) | asked Mar 24 '16, 7:42 a.m.
Hello All,

I am trying to write a query which fetches work items from a project area based on the filtering of Summary filed.

For E.g. say I enter the value in a text field as "hello" then all the work items in a particular project area whose summary contains "hello" should be fetched.

I am a little new to this. I tried few things.
How do I create a proper expression for that ?

Expression newExpr = new VariableAttributeExpression(attribute, AttributeOperation.CONTAINS,
                    What to pass here);

For the above expression how do I pass my Summary String ?


Thanks for any help :)


Regards,
Arshad

Accepted answer


permanent link
sam detweiler (12.5k6195201) | answered Mar 24 '16, 7:52 a.m.

Expression newExpr = new VariableAttributeExpression(attribute, AttributeOperation.CONTAINS, "string");
Arshad Adavani selected this answer as the correct answer

Comments
Arshad Adavani commented Mar 24 '16, 7:55 a.m.

Hi Sam,

Thanks for your response,

Expression newExpr = new VariableAttributeExpression(attribute, AttributeOperation.CONTAINS, "string"); doesn't work.

Expression newExpr = new AttributeExpression(attribute, AttributeOperation.CONTAINS,
                    "myText"); worked for me.
I think you also meant the same :)



sam detweiler commented Mar 24 '16, 7:57 a.m. | edited Mar 24 '16, 7:58 a.m.

right ,"string" meant whatever string of text you were searching for

and you got it.. thx for the feedback


Arshad Adavani commented Mar 24 '16, 8:13 a.m.

Hi Sam,

But how do I filter from a project area ?

I did this :

Expression summaryExpression = new AttributeExpression(attribute, AttributeOperation.CONTAINS, summaryText);

            IQueryResult<IResolvedResult<IWorkItem>> results = queryClient.getResolvedExpressionResults(projectArea,
                    summaryExpression, IWorkItem.FULL_PROFILE);


But it gives me the work items from all the project areas of a repository but it filters based on the text entered.


Regards,
Arshad


sam detweiler commented Mar 24 '16, 8:17 a.m.

you have to add another expression to the expression,
AND,
and then (projectarea)attribute equals ProjectArea

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.