How to Prevent Users from Moving Task to Closed State with a non-Zero value Remaining Work field in VSTS/TFS
One workflow problem we see in VSTS/TFS projects is people move the Task to Closed or Resolved state without updating the Remaining Work to Zero which leads to some incorrect project reports. In theory, there should be no Remaining work for Closed or Resolved Tasks. One of our customer had this below requirement. Wanted share how we customized the template to make it work as questioned below
Can we perform a check that prevents people from moving the state of a Task to Resolved or Closed with a non-zero Remaining Work?
We can achieve this by customizing the TFS/VSTS work item template in two ways. The 1st option will not allow the user to move the Task from Active to Closed state with a non-zero value in “Remaining work” field whereas 2nd option sets the remaining work to Zero when user moves the Task from Active to Closed state.
- Using the ALLOWED VALUES Rule on the Transition to the Closed state.
- Using the COPY Rule on the Transition to the Closed state.
- Using the ALLOWED VALUES Rule on the Transition to the “Closed” State.
- Export/Download the process template and open the Task work item template in any text editor.
- In the Transition to the “Closed” state add the below rule to the field Microsoft.VSTS.Scheduling.RemainingWork
This rule won’t allow the users to move the Task from Active to Closed state with a non-zero Remaining work.
Task is currently in Active State
When we move this task to Closed State It won’t all non-zero remaining work and it will show “0” as allowed value in the dropdown.
So, this way we can perform a check that prevents the users from moving Task to “Closed” state with non-zero Remaining work
2. Using the COPY Rule on the Transition to the “Closed” state.
Same requirement can also be achieved by using COPY rule on the transition to “Closed” state. We need to replace the above code snippet with the below code
This rule will set Remaining work to 0 after transitioning a Task work item from “Active” to “Closed” state.
The task is now in Active state.
When user move this Task to Closed State Remaining work is Set to Zero as shown below
We can see the same in work item history.