How to Set the List View Experience Programmatically into Modern Classic (ListExperienceOptions) in SharePoint Office 365 Programmatically

Sathish Nadarajan
 
Solution Architect
August 26, 2018
 
Rate this article
 
Views
3134

With the introduction of the Modern UI Experience, some of the applications are still required to be opening the Lists default views into Classic Experience. But again, it totally depends up on the client’s requirements. The below code can be used as part of the Provisioning engine to make the views default one.

 var lists = clientContext.Web.Lists;
                 clientContext.Load(lists, col => col.Include(l => l.ListExperienceOptions));
                 clientContext.ExecuteQuery();
                 foreach (var list in lists)
                 {
                     if (list.ListExperienceOptions != ListExperience.ClassicExperience)
                    {
 
                        list.ListExperienceOptions = ListExperience.ClassicExperience;
                         // list.ListExperienceOptions = ListExperience.NewExperience; 
                        // list.ListExperienceOptions = ListExperience.Auto; 
                        list.Update();
                    }
                 }
                 clientContext.ExecuteQuery();
 

The simple property ListExperienceOptions provide the option to change the default options of a list.

Happy Coding,

Sathish Nadarajan.

Author Info

Sathish Nadarajan
 
Solution Architect
 
Rate this article
 
Sathish is a Microsoft MVP for SharePoint (Office Servers and Services) having 15+ years of experience in Microsoft Technologies. He holds a Masters Degree in Computer Aided Design and Business ...read more
 

Leave a comment