Reputation: 1
I am a product owner using azure devops for backlog/story/bug/feature creation and organization. A repetitive task I find myself doing in is organizing the backlog by release version > priority > severity > last prioritized date to gain visibility. Because there are a lot of items, many existing before I came into the role, I was hoping there was an automated way to do this sorting task. I know I can create a query, but this doesn't allow for manual manipulation when it is needed. Is there another way to automate this, perhaps via script, or built-in function that I am not aware of?
Using a wiql query I can organize some items however once I create the query it becomes like a static report. I like the manual manipulation of the generic backlog but want to be able to quickly organize it via automation.
Upvotes: 0
Views: 460
Reputation: 294
You can manually define work item queries and edit them from Azure DevOps UI.
Or run Queries - Create - REST API (Azure DevOps Work Item Tracking) via PowerShell script to create a query in Azure DevOps organization.
POST https://dev.azure.com/{organization}/{project}/_apis/wit/queries/{query}?api-version=7.0
Here is an example:
# Convert PAT to a Base64 string.
$pat = "{Personal Access Token}"
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f "", $pat)))
# Set request headers.
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Authorization", ("Basic {0}" -f $base64AuthInfo))
$headers.Add("Content-Type", "application/json-patch+json")
$uri = "https://dev.azure.com/{organization}/{project}/_apis/wit/queries/{query}?api-version=7.0"
# Set request body and convert it to JSON type.
$body = @(
@{
"name": "All Bugs",
"wiql": "Select [System.Id], [System.Title], [System.State] From WorkItems Where [System.WorkItemType] = 'Bug' order by [Microsoft.VSTS.Common.Priority] asc, [System.CreatedDate] desc"
}
) | ConvertTo-Json -Depth 100
# Execute Invoke-RestMethod cmdlet to call the API and convert it response to JSON for better readable.
Invoke-RestMethod -Method POST -Uri $uri -Headers $headers -Body $body | ConvertTo-Json -Depth 100
Upvotes: 1