Showing posts with label Delete. Show all posts
Showing posts with label Delete. Show all posts

Monday, April 29, 2013

Cannot delete Column from List

When tried to delete some columns from list using GUI, Some of them don't give me option to delete.
Problem: I Can't delete column if it is sealed, hidden, or readonly
Solution: Change values of these properties to false before trying to delete

You can use PowerShell to change these properties and remove column from List like below:
$web = Get-SPWeb -identity SiteUrl
$list = $web.Lists[listName]
$column = $list.Fields[FieldName]
$column.Sealed = $false
$column.Hidden = $false
$column.ReadOnlyField = $false
$column.Update()
$list.Fields.Delete($column)

Monday, June 11, 2012

SharePoint Batch Insert/Update/Delete Performance

When you want to do bulk transaction insert, update, or delete.
If you have to update a larger number of items its highly recommended to not use the Update method on every item. Instead – use the batch update function ProcessBatchData provided by SPWeb.

StringBuilder query = new StringBuilder();
for (int itemIx=0;itemIx<100;itemIx++) {
  query.AppendFormat("" +
          "{1}" +
          "New" +
          "Save" +
          "{2}" +
       "", i, listGuid, someValue, "urn:schemas-microsoft-com:office:office#");
}
SPContext.Current.Web.ProcessBatchData("" +
    "{0}", query.ToString())

For more details of using ProcessBatchData check url:
http://stefan-stanev-sharepoint-blog.blogspot.com/2009/07/tips-for-using-spwebprocessbatchdata.html