4

I'm actually trying to add variation labels to a site using powershell script (SharePoint 2013), and i know there is no powershell script for the job so im looking at some c# object model and i found this cool guide which pointed me to add the variation labels to a hidden list.

http://blog.mastykarz.nl/programmatically-provisioning-variations-in-sharepoint-server-2010/

the script are good and the labels was added, i can see it from the variation page, however when i try to create the hierarchy it says

"No Variation Root Web has been set - hierarchies cannot be created until a Variation Root is set."

I have double checked at at least 1 label was checked with "IsSource" thus not sure what else to make this work. hope someone experience this before can help me out on this.

I'm able to resolve this by deleting all the labels created by the script, Create and delete a temp label from the page manually, then rerun the script to add the labels. and it works but this defeat the purpose of automate the site provision using scripts.

Many Thanks,

migrated from stackoverflow.com May 22 '13 at 17:28

This question came from our site for professional and enthusiast programmers.

1

Solved,

If you are creating variation labels using script/OM by manually adding labels (SPItems) into the hidden list (variation labels) for the first time (new site), because the variation home value are not stored on variation label list, there is no way to set the variation home when you have your source label created (using your code/script in this case) you need to add the variation home value in another hidden list "relationships list" ObjectID field.

  • Would you mind sharing your script? – user17229 May 24 '13 at 15:35
  • Hi, In powershell script how to pass value in $variationNode? We have to provide en-us,de-de language code. How to assign value in $variationNode? – user1337886 Jan 8 '14 at 13:08
1

Eric Soo found the answer: setting the ObjectID field. But a bit of powershell code might come in handy for people not knowing where to look for that specific field.

$list = $rootWeb.Lists |? {$_.RootFolder.ServerRelativeUrl -eq "/Relationships List"}
$items = $list.Items
foreach($item in $items)
{
  $item["ObjectID"] = "$($rootWeb.Url), /"
  $item.Update()
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.