It's all about the answers!

Ask a question

How to construct Expression for tags?

MooR Rathinasamy (413) | asked Dec 04 '19, 3:37 p.m.

 I am trying to construct a query thru Java API to fetch work items without any tags. 

IQueryableAttribute tagsQAttribute = qAttributeFactory.findAttribute(projectArea, IWorkItem.TAGS_PROPERTY, auditableCommon, monitor);
Expression tagDoesNotContain = new AttributeExpression(tagsQAttribute, AttributeOperation.NOT_EQUALS, "");

I am struck in constructing 'Expression' for 'tag' attribute. I don't think my implementation is correct. 

Can someone please help? 

One answer

permanent link
Ralph Schoon (63.3k33646) | answered Dec 05 '19, 2:56 a.m.
For all I can tell without actually trying, tags are treated as string. So you would use AttributeOperation.CONTAINS.
Not sure how multiple tags are represented for AttributeOperation.EQUALS. But the Equals usually does not make that much sense anyway, because there could be other tags than the one you are looking for, so contains and notcontains makes more sense.

MooR Rathinasamy commented Dec 06 '19, 10:52 a.m.

No luck. I tried Expression tagDoesNotContain = new AttributeExpression(tagsQAttribute, AttributeOperation.NOT_CONTAINS, ""), but the query returned all WIs instead of WIs with tags. I also tried CONTAINING, NOT_CONTAINING. I tried to put null instead of empty string, but the API didn't like it. 

In the Query editor, we form the condition as Tag 'is not' Unassigned. So i think we need to find a way to pass 'Unassigned'. 

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.