Question

Is there a way to mass update a bunch of views at the same time (add/remove columns to all views in a particular list)? We have a significant number of views, so it would be nice if we could update a bunch of them at the same time.

Was it helpful?

Solution

AFAIK SharePoint UI does not allow this but you could write a simple app to change your views. Check sample from Programmatically create a view (custom view) of a list and change the view below:

SPSite oSite = new SPSite([Site URL]);// [Site URL] change it to your sharepoint site URL
SPWeb oWeb = oSite.OpenWeb();
SPList oList = oWeb.Lists["shared documents"];  
SPViewCollection oViewCollection = oList.Views;

            string strViewName = "MyCustomView";

            System.Collections.Specialized.StringCollection viewFields =
            new System.Collections.Specialized.StringCollection();

            viewFields.Add("Name");
            viewFields.Add("Type");

            string query = "<Where><Eq><FieldRef Name=\"Name\"/>" +
                "<Value Type=\"Text\">mysample</Value></Eq></Where>";// here you can filter your items using the selected
                                                                         item in the dropdownlist
            oViewCollection.Add(strViewName, viewFields, query, 100, true, false);

 oWeb.Update();
Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top