Using Work Item Query Language (WIQL)
To return work items from the Azure DevOps WIQL data streams, you must specify a WIQL query in the data stream parameters.
WIQL is Azure DevOps' native query language for searching work items (including test cases), and lets you filter and retrieve results based on specified criteria such as state, assigned user, tags, iterations, and more.
This SQL-like language can be challenging to work with, as such the following content provides helpful information about writing WIQL queries in SquaredUp and aims to to demystify the query syntax with working examples.
Basic syntax
WIQL follows a simplified SQL-like structure:
SELECT [Fields]
FROM WorkItems
WHERE [Conditions]
ORDER BY [Field] [ASC|DESC]
The following table lists the keywords you'll use most when constructing WIQL queries in SquaredUp. See the WIQL syntax reference for more information.
Field naming conventions
All fields are redefined by Azure DevOps and are case-sensitive in WIQL. You must use the exact internal field names. For example:
Examples
The following examples demonstrate some common use cases when WIQL queries and provide working code snippets which you can copy and tweak.
Get tasks assigned to a specific user
Returns all Task
work items assigned to the specified user. Helpful for team leads or developers checking their personal work queue.
SELECT [System.Id], [System.Title]
FROM WorkItems
WHERE [System.WorkItemType] = 'Task'
AND [System.AssignedTo] = 'Jane Doe <[email protected]>'
Get work items with a specific tag
Fetches all work items that include the tag UI
. This is useful for filtering work items by topic, technology, or feature area.
SELECT [System.Id], [System.Title]
FROM WorkItems
WHERE [System.Tags] CONTAINS 'UI'
Get work items created in the last seven days
This query returns any work item created in the last 7 days. Ideal for reporting new incoming work items or backlog grooming.
SELECT [System.Id], [System.Title], [System.CreatedDate]
FROM WorkItems
WHERE [System.CreatedDate] >= @Today - 7
ORDER BY [System.CreatedDate] DESC
Get priority 1 test cases from a project
Finds test cases from the project squaredup
that have a priory of 1. Useful to identify important test cases that require action.
SELECT [system.Title]
FROM workitems
WHERE [system.WorkItemType] = 'Test Case'
and [priority] = 1
and [System.TeamProject] = 'squaredup'
Get unassigned work items with high priority
Finds work items that are not assigned to anyone and have a high priority (1 or 2). Use this to identify important work that still needs to be picked up.
SELECT [System.Id], [System.Title], [Microsoft.VSTS.Common.Priority]
FROM WorkItems
WHERE [System.AssignedTo] = ''
AND [Microsoft.VSTS.Common.Priority] <= 2
Get all active bugs
This query retrieves all work items of type Bug
that are currently in the Active
state. It orders the results so the most recently created bugs appear first. Use this to monitor ongoing issues.
SELECT [System.Id], [System.Title], [System.State]
FROM WorkItems
WHERE [System.WorkItemType] = 'Bug'
AND [System.State] = 'Active'
ORDER BY [System.CreatedDate] DESC