Freigeben über


Work Item rules workaround: Cannot close task unless Remaining Work is zero

In the last post in this series, Gregg blogged about restricting a bug such that only the creator can close it. This is the last post in this series of workarounds that we have been blogging about. We saved this as the grand finale for our series.

 

Customers have asked us: “I don’t want to allow users to close a task unless they have set Remaining Work to zero”

 

Here’s the solution:

1. Create a RemainingWorkValidation field

2. Add it to the form definition under the validation tab like the previous examples

3. Add the following rules to the RemainingWorkValidation field

<FIELD type="String" name="Remaining Work Validation" refname="Demo.RemainingWorkValidation">
<ALLOWEDVALUES>
<LISTITEM value="No Errors" />
</ALLOWEDVALUES>
<WHEN field="Microsoft.VSTS.Scheduling.RemainingWork" value="0">
<COPY from="value" value="No Errors" />
</WHEN>
</FIELD>

4. Add the following rule on the transition to closed state

<Transition from="Active" to="Closed">
<REASONS>
<REASON value="Deferred" />
<REASON value="Obsolete" />
<REASON value="Cut" />
<DEFAULTREASON value="Completed" />
</REASONS>
<FIELDS>
<FIELD refname="Demo.RemainingWorkValidation">
<WHENNOT field="Microsoft.VSTS.Scheduling.RemainingWork" value="0">
<COPY from="value" value="Remaining work has to be zero before closing the work item" />
</WHENNOT>
</FIELD>
</FIELDS>
</Transition>

5. Add the following rule to active state

<State value="Active">
<FIELDS>
<FIELD refname="Demo.RemainingWorkValidation">
<COPY from="value" value="No Errors" />
</FIELD>
</FIELDS>
</State>

 

6. Add the following rule to closed state

<State value="Closed">
<FIELDS>
<FIELD refname="Demo.RemainingWorkValidation">
<WHENNOT field="Microsoft.VSTS.Scheduling.RemainingWork" value="0">
<COPY from="value" value="Remaining work has to be zero before closing the work item" />
</WHENNOT>
</FIELD>
</FIELDS>
</State>

 

Here’s what it looks like:

image_thumb[2]

image_thumb[6]

A word of caution, one of our readers ran into an issue with Team System Web Access with the previous closing an iteration workaround where the UI doesn’t refresh on WHEN rule. Though I haven’t had a chance to try this workaround using Web Access, the WHENNOT rule used here may have a similar issue in Web Access.

Sunder Raman

Program Manager, Team Foundation Server

[Cross-posted from https://blogs.msdn.com/sunder]

Comments