How to Update the Regional Settings of SharePoint Office 365 Site Collection Programmatically using C# Patterns and Practices CSOM


Sathish Nadarajan
SharePoint MVP
Published On :   08 Jan 2019
Visit Count
Today :  1    Total :   357


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

clip_image002

2. Select the Regional Settings.

clip_image004

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

clip_image006

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.

Categories