19

Is there a way to query work items where a user was mentioned? I am able to receive 'hard-coded' results by querying for

"History"-"Contains word"-"\@Username",

but I want a generic version, which works for all users. (Opposed to writing one query for every user)

5 Answers 5

39

Use this predicate:

  • Field: "ID"
  • Operator: "In"
  • Value: "@RecentMentions"

This automatically filters for work items, where current user has been mentioned.

I found it in predefined filter "Mentioned" in "Work Items" section. If you click on "Open in Queries" button, you will get a query with above filter. (This section can even remove the need for that query...)

Note: at present time, works only in VSTS.

4
  • Error says ID and @RecentMentions are a different data type, even with the "In" operator. Feb 12, 2019 at 1:40
  • I cannot reproduce that behaviour; it is still working for me. If I use an operator different than "In" it is said that @RecentMentions is an array and as soon as I write "@" default variables are shown for autocompletion. What environment are you using, TFS or DevOps? Feb 14, 2019 at 13:56
  • In VS, apparently not supported there. Works in DevOps. My bad, didn't see the tag. I'll remove my downvote but you have to make an edit. Feb 15, 2019 at 16:44
  • This worked for me in Azure DevOps which is essentially SaaS VSTS Feb 17 at 16:26
5
https://{org}.visualstudio.com/{project}/_workitems/mentioned/

This would achieve the same result.

1

There is no way to achieve this by work item query directly just as starain mentioned. You can create a custom hub or custom widget by using VSTS Extension to show these information in web portal.

1

You can’t achieve that through work item query directly, you could build a app to retrieve data through REST API (https://www.visualstudio.com/en-us/docs/integrate/api/wit/wiql), change query text according different conditions (e.g. users)

2
  • Ok, but as far as I can see there is no way to integrate these into the visualstuioonline.com query interface/dashboards
    – floAr
    Aug 30, 2016 at 11:07
  • As Eddie said that, you can create a VSTS extension. Sep 2, 2016 at 6:41
0

Your query should be something like this Select Id,Title From WorkItems Where ID IN (@RecentMentions) order by [System.ChangedDate] desc

here is the reference for rest of the macro's available in ADO rest API. https://learn.microsoft.com/en-us/azure/devops/boards/queries/query-operators-variables?view=azure-devops

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.