We have a requirement to change the Display Name (i.e. the Title property) of the Title field of a custom list during site provisioning.
The code to do this is simple, but some for reason it would just not work. There are no exceptions but the change won’t stick. If we take the same code, and apply it to some other fields, then it works for that field. This suggests that there are something special about the Title column.
Here are the methods that we have tried:
- Use feature receiver code
- Use site provisioning code
- Change the list definition schema
- Use feature stapling
The strange thing is the 1st option works when the feature is deactivated and reactivated after the site has been created, but does not work during site provisioning.
This hints that this particular change must be applied after the site has been created.
Unfortunately there are no WebProvisioned event in 2007 (but there is in 2010!!!). One way to get around this is to use the method described here: http://sharepointmagazine.net/technical/development/introduction-to-sharepoint-feature-stapling-part-2, which essentially involves creating another thread and monitor the SPWeb.Provisioned attribute.
We found that using this method works! We were able to change the Title property of the Title field during site creation. (Hoorray!! took us nearly a week of investigation).
However, it is worthwhile to note that this may not work if the site was created through stsadm, as “the tool may exit before the extra thread gets executed” (http://social.msdn.microsoft.com/Forums/en/sharepointdevelopment/thread/77f239f9-64a9-4393-9ec7-c0b08b55c7f4).
I stress that this convoluted approach is necessary only for updating the Title column. Other columns work perfectly through the normal Provision method of the SPWebProvisioningProvider class.