SP2010: Deleting variation left-overs

Today I was tasked with creating a partial copy of a web. For those kinds of things, I am very glad I can make use of AvePoint DocAve tooling. Deployment manager and Content Manager are great for copying, moving and doing all kinds of other stuff within or between SharePoint farms.

Anyway. After copying my site, I found out that there were left-overs from the variation labels used in the source site I used to copy from. The variation labels page showed one label (subsite) which wasn’t copied so it didn’t exist. Upon my attempt to delete that label, SharePoint responded that the corresponding web could not be found (“there is no web named…”. Finally, an error which makes sense! But an error nonetheless and one that’s not that easy to fix.

You might think: I’ll just create an empty subsite with the correct name / URL and then delete it. I came up with the same only to find out that this doesn’t work. The variation system works with hidden data to keep track of what entities have been copied from the root variation label onto the culture specific sites. So your next best bet would be to find out where those sites are stored.

A quick search on the interwebs told me that a SPWeb object has two important properties when it comes to variations, namely:

  • _VarLabelsListId
  • _VarRelationshipsListId

These properties contain the ID’s of the lists in which variation data is stored. The first list contains the labels , the second list contains an entry for each item copied by the variations system, keeping track of source and target data. Now if you really would like to kill your entire variations structure in your site collection, simply delete the data in these lists. Warning: this will do a “factory reset” for your variations, leaving it completely non functional!

Example of a simple PowerShell script to do so:

$site = Get-SPSite http://www.contoso.com
$web = $site.RootWeb
$listId = [System.Guid] $web.AllProperties["_VarRelationshipsListId"]
$list = $web.Lists[$listId]
$i = $list.ItemCount - 1
while ($i -gt -1) { $list.Items[$i].Delete(); }

And same goes for _VarLabelsListId of course. By the way, you can also inspect the list object to find out the URL of the list. This would be something like:

/Variation Labels/
/Relationships List/

Another example of lack of consistency, since they are both lists, but only one has the “List” postfix. Ah well.

One last remark. When you delete your variations structure, but the welcome page of your site was pointing to VariationRoot.aspx, this will now break saying there are no variations to point you to. Hey! Another pretty valid error message! Here’s  a simple script to correct that:

$folder = $web.RootFolder
$folder.WelcomePage = "default.aspx"

Will obviously set the welcome page to default.aspx, but you might want to use something like “/Site Pages/Home.aspx” instead, based on how your site is structured.

Note: although this article is based on SP2010, the same will probably work for 2013 as well.


Related posts

Latest posts

Leave a Comment

Leave a Reply

Your email address will not be published. Required fields are marked *