How To Update The Regional Settings Of SharePoint Office 365 Site Collection Programmatically Using C# Patterns And Practices CSOM

Sathish Nadarajan
 
Solution Architect
January 8, 2019
 
Rate this article
[Total: 0    Average: 0/5]
 
Views
1568

In this article, let us see how to update the Regional Settings of SharePoint Office 365 Programmatically using C# PNP.

Before proceeding to the code snippet, let us see how to do that manually.

1. Go to Site Settings

2. Select the Regional Settings.

We are going to update the Locale Dropdown to various languages.

The small piece of code is as follows.

 public static void UpdateLocaleID()
         {
             try
             {
                 OfficeDevPnP.Core.AuthenticationManager authMgr = new OfficeDevPnP.Core.AuthenticationManager();
 
                 using (var ctx = authMgr.GetSharePointOnlineAuthenticatedContextTenant(siteUrl, userName, password))
                 {
                     Web web = ctx.Web;
                     ctx.Load(web);
 
                     #region Language settings
                     // Set regional settings to host web and execute the query
                     web.RegionalSettings.LocaleId = uint.Parse("1036");
                     web.RegionalSettings.Update();
                     ctx.ExecuteQuery();
 
                     #endregion
                 }
             }
             catch (Exception ex)
             {
                 System.Console.WriteLine("Exception occurred : " + ex.Message);
                 System.Console.ReadLine();
             }
         }
 

Happy Coding,

Sathish Nadarajan.

Author Info

Sathish Nadarajan
 
Solution Architect
 
Rate this article
[Total: 0    Average: 0/5]
 
Sathish is a Microsoft MVP for SharePoint (Office Servers and Services) having 13+ years of experience in Microsoft Technologies. He holds a Masters Degree in Computer Aided Design and Business ...read more
 

Leave a comment