Tuesday, September 25, 2007 8:38 PM
by
trent_nix
Work Item Customization: Set a Field Value That Cannot Change
I was doing a bit of work item customization today when I ran into an interesting, but common problem. The client wanted a field, specifically the 'Work Remaining' field on a Sprint Backlog Item, a work item in the Conchango Scrum template, to automatically be set to 0 when the work item state is set to Done. Easy enough.
<STATE value="Done">
<FIELDS>
<FIELD refname="Conchango.VSTS.Scrum.WorkRemaining">
<COPY from="value" value="0" />
</FIELD>
</FIELDS>
</STATE>
But really, they wanted to make sure that the value is both set to 0 and read only so that the value never changes when the work item is marked as Done. If the work is complete, there should be no remaining work and if any additional work is identified, the item should be set to be In Progress. So the obvious choice is to add <READONLY /> or <FROZEN /> inside the FIELD tag. As obvious as this seems, it won't work. The result of the COPY doesn't stick or doesn't happen, depending on which you do. Either way, it's not what was ordered.
The get around this problem, I needed to duplicate a situation where I could set the value for the Work Remaining field to 0 and create a situation where the value could not be changed, so I just turn the Work Remaining field into a drop down when the work item is in the Done state and allow only a single value, 0!
<STATE value="Done">
<FIELDS>
<FIELD refname="Conchango.VSTS.Scrum.WorkRemaining">
<COPY from="value" value="0" />
<ALLOWEDVALUES>
<LISTITEM value="0" />
</ALLOWEDVALUES>
</FIELD>
</FIELDS>
</STATE>
It's a hack, but it manages to overcome an unfortunate limitation.