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">
   <REASONS>
    <REASON value="Fixed">
      <FIELDS>
        <FIELD refname="Microsoft.VSTS.Common.ResolvedReason">
          <COPY from="value" value="Fixed" />
        </FIELD>
      </FIELDS>
    </REASON>
    <REASON value="Deferred">
      <FIELDS>
        <FIELD refname="Microsoft.VSTS.Common.ResolvedReason">
          <COPY from="value" value="Deferred" />
        </FIELD>
       </FIELDS>
    </REASON>
    ...
</Transition>

 

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

image 

 

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

Comments

  • Anonymous
    April 22, 2009
    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 ? Thx

  • Anonymous
    April 23, 2009
    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. Thanks, Sunder

  • Anonymous
    May 18, 2009
    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?

  • Anonymous
    May 18, 2009
    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" />              </WHEN>            </FIELD> It will check and if the resolvedreason hasn't be already set, it will then set it to the default.   Thanks!

  • Anonymous
    May 18, 2009
    Good point on the default reason, KE. Thanks!