Work Item rules workaround: Saving the resolved reason

In our last post in this series, Gregg blogged about securing a work item type on our team blog. Another question along these lines: “How can I save the resolved reason? I want to create metrics based on how bugs were resolved, but the value of the ‘Reason’ field is changed when the bug is closed”


Here’s the solution:

1. Add “Microsoft.VSTS.Common.ResolvedReason” field to the form definition

2. Add the following rules to the workflow transition from “Active” to “Resolved”

<Transition from="Active" to="Resolved">
    <REASON value="Fixed">
        <FIELD refname="Microsoft.VSTS.Common.ResolvedReason">
          <COPY from="value" value="Fixed" />
    <REASON value="Deferred">
        <FIELD refname="Microsoft.VSTS.Common.ResolvedReason">
          <COPY from="value" value="Deferred" />


Here’s the end result; I am displaying the field in the Details tab of the Bug form:



This workaround works by copying the resolved reason when the bug is resolved off into the Resolved Reason field.

Comments (5)

  1. terrycbta says:

    Hi Sunder,

    I read your post but something goes wrong in my side.

    I understand that field [Resolved Reason] keep the desered value.

    Based upon your screenshot, I can read:

    [State]= Resolved

    [Reason]= Fixed (read only)

    OK now supposed that I have:

    [State]= Resolved

    [Reason]= Duplicate(read only)

    Now I want to change [state] from ‘resolved’ to ‘Close’. And of course I want to keep reason=Duplicate.

    What happens is:

    [State]= Closed -> OK

    [Reason]= Fixed (this is default value for TFS)

    [ResolvedReason]= Duplicate -> OK

    Is there any chance to keep [Reason]=Duplicate ?


  2. Sunder Raman says:

    Hello Terry,

    Since the Reason field changes when you close the work item, this workaround let’s you preserve the resolution (in your case Duplicate) in the Resolved Reason field.

    To find out the acutal resolution when your bug was resolved, you will need to look at Resolved Reason instead of Reason.



  3. KE says:

    Hi Sunder,

    This only seems to work if there isn’t a default reason associated with the transition.  If there is a default transition, the the reason that is picked up is the original reason from the previous state change.  Is there a work around to this behavior?

  4. KE says:

    Hi Sunder,

    I figured out how to handle the default reason.  If I insert this code into the fields

               <FIELD refname="Microsoft.VSTS.Common.ResolvedReason">

                 <WHEN field="Microsoft.VSTS.Common.ResolvedReason" value="">

                   <COPY from="value" value="Completed" />



    It will check and if the resolvedreason hasn’t be already set, it will then set it to the default.  


  5. Sunder Raman says:

    Good point on the default reason, KE. Thanks!