How to show mapping of 4 to 1 fields in azure devops public domain

Subhash1 Katke 0 Reputation points
2025-06-10T06:54:29.1433333+00:00

I have four input fields and their corresponding dropdown values, and the final output field, "Severity," is what I want to populate based on the values of these four input fields.

Below are the four fields and their values, and based on the selections of "Yes" or "No," we need to populate the "Severity" field.User's image

Can you please provide me with a solution on how I can develop this?

Azure DevOps
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Durga Reshma Malthi 3,735 Reputation points Microsoft External Staff Moderator
    2025-06-10T10:20:10.2766667+00:00

    Hi Subhash1 Katke

    You can achieve this mapping in Azure DevOps by using work item rules and custom script.

    Using work item rules:

    1. 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.
    2. 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. User's image
    3. 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.
    4. Also add the severity field with Picklist string values: Blocker, Critical, Minor, Major, Normal in the work item process.
    5. Now Go to Rules section -> Add Rule -> Add rules as required
      1. If all four fields are "Yes", set Severity = Blocker.
      2. If three fields are "Yes", set Severity = Critical.
      3. If two fields are "Yes", set Severity = Major.
      4. If one field is "Yes", set Severity = Normal.
      5. If none are "Yes", set Severity = Minor. User's image
    6. Save the changes and test it.

    Alternatively, you can use custom script:

    You have already four fields in Azure DevOps:

    1. Is this problem easily encounterable by the majority of users? (Yes/No)
    2. Is this core functionality failure? (Yes/No)
    3. Is it a crash? (Yes/No)
    4. 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:

    https://learn.microsoft.com/en-us/azure/devops/organizations/settings/work/custom-rules?view=azure-devops

    Hope this helps!

    Please Let me know if you have any queries.


  2. Uzair2 Khan 0 Reputation points
    2025-06-11T07:06:12.4666667+00:00

    Hi Durga Reshma Malthi,

    we cannot add 2 when clauses in the same rule

    When Field 1=yes AND Field 2=No AND field 3=Yes -> Severity=Minor

    It works for max 1 field

    0 comments No comments

  3. Durga Reshma Malthi 3,735 Reputation points Microsoft External Staff Moderator
    2025-06-11T07:37:12.8433333+00:00

    Hi Uzair2 Khan

    That might be true. Thanks for the update, Alternatively, I suggested the custom script.

    You can also implement this using JavaScript for a web-based UI:

    1. Create a Basic HTML Page:
         <!DOCTYPE html>
         <html lang="en">
         <head>
             <meta charset="UTF-8">
             <meta name="viewport" content="width=device-width, initial-scale=1.0">
             <title>Severity Calculator</title>
         </head>
         <body>
             <h2>Determine Severity Based on Inputs</h2>
             <label>Is this problem easily encounterable by majority of the users?</label>
             <select id="encounterable">
                 <option value="Yes">Yes</option>
                 <option value="No">No</option>
             </select>
             <br><br>
             <label>Is this a core functionality failure?</label>
             <select id="coreFailure">
                 <option value="Yes">Yes</option>
                 <option value="No">No</option>
             </select>
             <br><br>
             <label>Is it a crash?</label>
             <select id="crash">
                 <option value="Yes">Yes</option>
                 <option value="No">No</option>
             </select>
             <br><br>
             <label>Is it giving factually wrong info?</label>
             <select id="wrongInfo">
                 <option value="Yes">Yes</option>
                 <option value="No">No</option>
             </select>
             <br><br>
             <h3>Severity: <span id="severity">Unknown</span></h3>
             <script src="script.js"></script>
         </body>
         </html>
      
    2. script.js file to handle dynamic updates:
         <script>
           function determineSeverity(a, b, c, d) {
             const combo = `${a}${b}${c}${d}`;
             const severityMap = {
               'YesYesYesYes': 'Blocker',
               'YesYesYesNo': 'Blocker',
               'YesYesNoYes': 'Blocker',
               'YesYesNoNo': 'Blocker',
               'YesNoYesYes': 'Critical',
               'YesNoYesNo': 'Critical',
               'YesNoNoYes': 'Major',
               'YesNoNoNo': 'Normal',
               'NoYesYesYes': 'Critical',
               'NoYesYesNo': 'Critical',
               'NoYesNoYes': 'Major',
               'NoYesNoNo': 'Major',
               'NoNoYesYes': 'Major',
               'NoNoYesNo': 'Major',
               'NoNoNoYes': 'Normal',
               'NoNoNoNo': 'Minor'
             };
             return severityMap[combo] || 'Unknown';
           }
           const inputs = ['field1', 'field2', 'field3', 'field4'];
           function updateSeverity() {
             const values = inputs.map(id => document.getElementById(id).value);
             const severity = determineSeverity(...values);
             document.getElementById('severityOutput').innerText = severity;
           }
           // Attach event listeners
           inputs.forEach(id => {
             document.getElementById(id).addEventListener('change', updateSeverity);
           });
         </script>
      

    Save the file as index.html -> Open it in your browser -> Select different Yes/No combinations from the dropdowns and watch the "Severity" output update in real time.

    Hope this helps!

    Please Let me know if you have any queries.

    If you found the information helpful, please click "Upvote" on the post to let us know and consider accepting the answer as the token of appreciation. Thank You.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.