3

Can anyone tell me how to create variation labels using CSOM?

0

2 Answers 2

-4

I dont think you can create the variation label using the CSOM. I think you need to use to the Powershell or c#. here is the blog:

Automate Variations in SharePoint 2013 Using PowerShell & C#

He wrote the code for both C# and script for PowerShell.

3
  • Is there any reason to down vote? You did it could you please tell me why?
    – Waqas Sarwar MVP
    Commented Aug 25, 2014 at 12:05
  • 1
    The answer has been downvoted since Iam pretty sure it is incorrect, I guess it is based only on googling..but it does not mean it could not be done. See for example this answer sharepoint.stackexchange.com/questions/88367/… Evidently the same approach could be applied for creating variation labels. Besides in SharePoint 2013 API was introduced Microsoft.SharePoint.Client.Publishing namespace that contains VariationLabel class, if you are really interested, see for example msdn.microsoft.com/en-us/library/hh627977(v=office.12).aspx Commented Aug 25, 2014 at 12:59
  • but question is can you create the label? which i think you cannot.
    – Waqas Sarwar MVP
    Commented Aug 25, 2014 at 16:02
11

How to create Variation Labels in SharePoint 2013/Online via CSOM

SharePoint 2010/2013 CSOM API does not expose any specific methods for creating Variation Labels, but you could use the following class for that purpose.

VariationsClient class is intended for managing Variation Labels in SharePoint 2013.
The following operations are currently supported:

  • VariationsClient.CreateLabel method is used for create Variation Label
  • VariationsClient.GetLabelsList method gets Variation Labels on site

Usage

using (var ctx = new ClientContext(url))
{ 
    var variationsClient = new VariationsClient(ctx);
    var siteLanguages = new[] {"en-US","ru-RU","fi-FI","nl-NL"};
    foreach (var language in siteLanguages)
    {
        var isSource = (language == "en-US");
        variationsClient.CreateLabel(new CultureInfo(language), isSource);    
    }
}

Result

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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