WIQL assistance for Triggers

Originally asked by Howard Kenny on 19 January 2021 (original question)


Hi,

I’m trying to create a Trigger in DevOps, which we’ve not done before. Struggling to understand what the syntax needs to be. We need the Trigger to be driven by a Tag. The below don’t work. Any ideas please?

[Tags] = ‘HKTest’

[System.Tags] = ‘HKTest’


Answer by Ariel Aguilar on 23 March 2021

Hi Howard,

You can create triggers filtering work items that satisfy specific conditions.

Example 1

Trigger all work items whose type is “Task”:

[Work Item Type]``= 'Task'

WIQL - Work Item Query Language

Triggers on Azure DevOps are based on WIQL - Work Item Query Language.

When writing Azure DevOps Node triggers, you don’t need the entire query, just the conditions found in the WHERE clause of the WIQL to filter the work items.

You can find more information about WIQL on:
WIQL Syntax - https://docs.microsoft.com/en-us/azure/devops/boards/queries/wiql-syntax?view=azure-devops
WIQL Rest API - https://docs.microsoft.com/en-us/rest/api/azure/devops/wit/wiql/query%20by%20wiql?view=azure-devops-rest-5.1

Example 2

Triggers all the Work Items whose type is “Task” and project is “BatCave” and is assigned to “Bruce Wayne” and State is “Doing” and Area Path is “BatCave\Operation” and has “azure” as one of its tags.

[Work Item Type]``= 'Task' AND``[Team Project]``= 'BatCave' AND``[System.AssignedTo]``= 'Bruce Wayne' AND``State``= 'Doing' AND``[Area Path]``= 'BatCave\Operation' AND``[System.Tags] Contains``'azure'

Example 3

The trigger below uses the macro “@today” and will select all work items created two days ago.

[System.CreatedDate]``= @``today-``2

Field Names

You can specify either the reference name or the friendly name. The following examples are valid WIQL syntax:

  • Reference name with spaces: [System.AssignedTo] ...
  • Friendly name with spaces: [Assigned To] ...
  • Names without spaces don’t require square brackets: ID, Title, State ...

Kind regards,
Ariel


This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.