Tuesday, 28 June 2016

Delete Read only field from Sharepoint list/library

How to remove/delete a read only field programatically? 




SPSecurity.RunWithElevatedPrivileges(delegate
{
    using (SPSite spSite = new SPSite("siteurl"))
        using (SPWeb spWeb = spSite.OpenWeb())
        {
          SPList list = spWeb.Lists["ListName"];
                    SPField spField = list.Fields["ColumnName"];
                    spField.ReadOnlyField = false ;
                    spField.Update();
                    spField.Delete();
                    spField.ParentList.Update();
        }
});

                    

No comments:

Post a Comment