You can achieve this mapping in Azure DevOps by using work item rules and custom script.
Using work item rules:
- Go to Azure DevOps -> Organization Settings -> Process -> If using the system process like Basic, Agile, CMMI -> Click on 3 dots right side of process -> Click Create Inherited Process.
- Once Inherited process was created -> Select work item type like bug, epic, task etc; -> Click New field -> Enter the field name (Is this problem easily encounterable by majority of the users) and choose the field type (Boolean, Picklist (string)) and set the default values as Yes and No -> Click on Add field.
- Create the remaining 3 custom fields (Is this core functionality failures, is it a crash , Is it giving factually wrong info) with Yes/No in this process.
- Also add the severity field with Picklist string values: Blocker, Critical, Minor, Major, Normal in the work item process.
- Now Go to Rules section -> Add Rule -> Add rules as required
- If all four fields are "Yes", set Severity = Blocker.
- If three fields are "Yes", set Severity = Critical.
- If two fields are "Yes", set Severity = Major.
- If one field is "Yes", set Severity = Normal.
- If none are "Yes", set Severity = Minor.
- Save the changes and test it.
Alternatively, you can use custom script:
You have already four fields in Azure DevOps:
- Is this problem easily encounterable by the majority of users? (Yes/No)
- Is this core functionality failure? (Yes/No)
- Is it a crash? (Yes/No)
- Is it giving factually wrong info? (Yes/No)
PowerShell script that analyzes the input fields and assigns the correct Severity:
# Function to determine Severity based on input fields
function Determine-Severity($easilyEncounterable, $coreFailure, $isCrash, $factuallyWrong) {
if ($easilyEncounterable -eq "Yes" -and $coreFailure -eq "Yes" -and $isCrash -eq "Yes" -and $factuallyWrong -eq "Yes") {
return "Blocker"
} elseif ($easilyEncounterable -eq "Yes" -and $coreFailure -eq "Yes" -and $factuallyWrong -eq "Yes") {
return "Critical"
} elseif ($easilyEncounterable -eq "Yes" -and $coreFailure -eq "No" -and $isCrash -eq "Yes") {
return "Major"
} elseif ($factuallyWrong -eq "Yes") {
return "Normal"
} else {
return "Minor"
}
}
# Example usage: Input values dynamically retrieved from Azure DevOps API
$easilyEncounterable = "Yes"
$coreFailure = "No"
$isCrash = "Yes"
$factuallyWrong = "No"
# Get Severity based on inputs
$severity = Determine-Severity $easilyEncounterable $coreFailure $isCrash $factuallyWrong
Write-Host "Severity Level Assigned: $severity"
Use a REST API call to retrieve work item values.
# Define Azure DevOps credentials
$organization = "YourOrganization"
$project = "YourProject"
$workItemId = "12345"
$pat = "YourPATToken"
$headers = @{
Authorization = "Basic " + [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(":$pat"))
"Content-Type" = "application/json"
}
# Retrieve Work Item Data
$workItemUrl = "https://dev.azure.com/$organization/$project/_apis/wit/workitems/$workItemId?api-version=7.1"
$response = Invoke-RestMethod -Uri $workItemUrl -Headers $headers -Method Get
# Extract field values
$easilyEncounterable = $response.fields.'Custom.IsProblemEasilyEncounterable'
$coreFailure = $response.fields.'Custom.IsCoreFunctionalityFailure'
$isCrash = $response.fields.'Custom.IsCrash'
$factuallyWrong = $response.fields.'Custom.IsGivingWrongInfo'
# Get Severity
$severity = Determine-Severity $easilyEncounterable $coreFailure $isCrash $factuallyWrong
Write-Host "Calculated Severity: $severity"
# Update Work Item Severity
$updateJson = @{
"fields" = @{
"Custom.Severity" = $severity
}
} | ConvertTo-Json -Depth 10
$updateUrl = "https://dev.azure.com/$organization/$project/_apis/wit/workitems/$workItemId?api-version=7.1"
Invoke-RestMethod -Uri $updateUrl -Headers $headers -Method Patch -Body $updateJson
Additional References:
Hope this helps!
Please Let me know if you have any queries.