Can’t change Display Name (or Title property) of Title field during site provisioning

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:

  1. Use feature receiver code
  2. Use site provisioning code
  3. Change the list definition schema
  4. 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.

Advertisements

About Bernado

Based in Australia, I am a freelance SharePoint and Dynamics CRM developer. I love developing innovative solutions that address business and everyday problems. Feel free to contact me if you think I can help you with your SharePoint or CRM implementation.
This entry was posted in SharePoint. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s