azure-devopstfs

How to Set Conditional State Transitions Based on Boolean Field in Azure DevOps WITD XML


I am customizing the workflow for a work item type in Azure DevOps and need to set state transitions based on the value of a boolean custom field (Abc.CustomField). Specifically:

If Abc.CustomField is true, the next state available in state dropdown should be "Done". If Abc.CustomField is false, the next state available in state dropdown should be "Terminated".


Solution

  • Based on your description, you need to set the state value based on the custom work item field value.

    To meet your requirement, you can define the conditional-based values and rules in XML Process.

    Here is an example: We can use WHEN to set the condition based on the Abc.CustomField

    <FIELD name="State" refname="System.State" type="String" reportable="dimension" />
           <ALLOWEDVALUES>  
               <LISTITEM value="New" />  
               <LISTITEM value="Active" />  
               <LISTITEM value="Done" /> 
               <LISTITEM value="Terminated" />  
           </ALLOWEDVALUES>   
           <WHEN field="Abc.CustomField" value="true">  
               <ALLOWEDVALUES>  
                   <LISTITEM value="Done" />                
               </ALLOWEDVALUES>  
           </WHEN>  
           <WHEN field="Abc.CustomField" value="false">  
               <ALLOWEDVALUES>  
                   <LISTITEM value="Terminated" />                
               </ALLOWEDVALUES>  
           </WHEN>  
    
    </FIELD>  
    

    For more detailed info, you can refer to this doc: Assign conditional-based values and rules

    If you are using inherited processes, you can use the Work Item Rule to achieve the same feature.