Sunday, 27 October 2013

TFS - Delete WIT Custom Fields Permanently


When you delete a custom filed from a Work Item Template and import is it really deleted from TFS fully? Or is it only hidden from that work item type and remains in TFS?

To find out the answer I have done a small experiment.

1. Fist I have added a new HTML type filed "CH.Test1" and added a HTML field control to User Story work item.



2. When I have imported the template I can see my new field in User Story work item.


3. I saved some data to newly created field.


4. Then I deleted the HTML field control and the filed "CH.Test1" in the template.


5. When viewed the previous user story I could not see the field and that is correct and field is deleted.


6. But what happens if I add the field again? To Investigate I tried adding the field with Same Reference Name but with a different name.



7. Import failed with

Error importing work item type definition:

TF26177: The field CH.Test1 cannot be renamed from 'Chaminda Test 1' to 'Chaminda Deleted And Added Field'.


8. This means that the field was not really deleted. To test I changed to the initial name "Chaminda Test 1"


9. Import was successful and when I viewed the same user story data I had entered before deleting the field was still available. It looked clear that even if I deleted a field from WIT template and import it did not delete the field or the data from TFS Collection.


8. Search in MSDN got me here Manage work item fields [witadmin]
I used witadmin listfields with Reference Name to see my field. The command gave the details of the field, whether it was used, In which project it was used.


9. Again I tried deleting from template and import.


10. When I used witadmin listfields with Reference Name, it clearly showed field is existing in collection but "Not In Use" in any team project.


11. How to delete permanently? I used witadmin deletefield with Reference Name, this gave me a warning and a confirmation question. When said Yes deleted. To verify I executed witadmin listfields with Reference Name again and an error shown that the field does not exist.


12. To confirm I tried re-adding the field with same Reference Name but with a different Name, and a different data type (String).



13. This time I did not get TF26177 when the template was imported.


Conclusion: When a field is deleted from the work item template and imported it remains in TFS collection and previously entered data related to work item also preserved. To delete the field permanently witadmin deletefield can be used and all data and the field will be completely destroyed with this command.

1 comment:

Anonymous said...

Hey,
Have you noticed that even though the field is deleted, you can still select the field in the query builder? Any idea on how to remove the field from that list?