TFS 2015.2.1. I have a workitem with custum fields. I have seen that if I set a default value (a new rule for the template) this does not auto-populate pre-existing records. While new records get the default value, the existing records remain with no value in the new field: if I open the workitem I can see the field with the default value populated (also with old records) but this value is saved only when you save the workitem. You can see this with a query: if you search workitems with "the default value" you will find only new workitems or old workitems re-opened and re-saved. Is it possible to save a default value in old records?
3 Answers
I've tested in TFS 2015.3, when apply a default value with DEFAULT rule to a custom field like the example below, the pre-existing records also has this value:
<FieldDefinition name="version" refname="version.version" type="String">
<DEFAULT from="value" value="1.0" />
</FieldDefinition>
You may upgrade your TFS to TFS 2015.3, and set a similar rule as my example, your pre-existing records should have the default value too.
I've had this "issue" in the past, and your observations are right. Changing rules on a field in the work item template won't affect existing records until you open and save them. Therefore, you'll have to update existing records to populate your new fields with their respective default value.
You may use Excel to mass-edit the existing records and achieve your goal.
TL;DR; I have has this problem before and created a tool to bulk edit work items and fill out the values
1-1000 Work Items
Just use the Web Access bulk edit. Multi select in the web, right click, and select Edit.
1000-10,000 Work Items
Create a Query and then Open Excel and connect to TFS/VSTS and open the query. Bulk edit from here and publish.
10,000+ Work Items
Us the VSTS Sync Migration (https://marketplace.visualstudio.com/items?itemName=nkdagility.vsts-sync-migration) tools to bulk edit one or more fields in any number of work items. Use the "UpdateWorkItem" processor with as many "Field Mapps" to make the changes that you need.
Note: There are some inaccuracies in the documentation but if you install with Chocolatey you can use "vstssyncmigrator init" from anywhere.