Monday, November 5, 2012

Beware SharePoint Site Columns In Site Templates

This one's a real doosy but very easy to recreate.

First, the what I expect scenario:

  1. First create a site collection with a blank root site.
  2. From the root site create two child sites, again both blank.
  3. On both child sites create a Site Column called Project Id, single text value, with a default of P1 for the first and P2 for the second.
  4. Now add an Annoucment list  to both child sites and add the corresponding site column to each list.
  5. Now go back to the Site Column definition of the first site and change the default value for Project Id to "Proj1" and be sure to keep the "Update all list columns based on this site column" set to to yes.
  6. Then go back to the Announcements list on the other (second) child site and check the list settings to see what the Project Id column is set to. Note that this is the List column not the site column it is based on. The default at the list level should still be P2.

This is of course exactly what we would expect. Changing the default of the site column only affects that site and child sites under it, but certainly not sibbling sites.

Now create a Site Template from one of the child sites and stand up a couple of more sites based on this site template as children to the root site, so sibblings to the site the template was generated from.

And now change the Site Column default for Project Id on one of these new child sites to say "PX" and again be sure to keep the "Update all list columns based on this site column" set to to yes.

Now start looking around.

You will find that while all the Site Column defaults other than the one you worked on are unchanged, the List Column defaults have been changed for the current site, the other site generated from that teamplte, and also in the site that the template was generated from. But apparently not the other sibbling site that was generated manually and has nothing to do with the tempalte.

It is of course, my old friends SPSolutionExporter and associated, though in this case the problem is most likely with the import/stand up process.

I have no work around for this at the moment. Just don't include Site Columns in Site Templates unless you will only ever have one instance of that site in a collection.

You know, life sucks enough without having to add SharePoint to it.




No comments:

Post a Comment