• This email address is being protected from spambots. You need JavaScript enabled to view it.

    Recent items


Tuesday, 04 March 2014 22:46

How to use and configure large lists


we need to store into lists a lot of elements. All developers that know SharePoint knows that in the OOB views there is the limit of 5000 items.
I want suggest these recommendations to create a definition for a list that have a lot of elements:

  • allow the folders and create an event receiver in order to store the items into the folders (maximum 5000 items for each folder)
  • enable one o more indexed columns (not on the ID field and the best fields are text fields). Each column that will be used for where condition or $filter condition need to enabled as indexed column
  • if you are quering on lookup column, you must use this

<FieldRef Name='ColumnName' LookupId='TRUE' /><Value Type='Integer'   >LOOKUP_ITEM_ID</Value>

In the case that you have already the list and you have exceeded the threshold, these are the steps for the work around:

  • from the central administration, modify the threshold value up to the current list count on the current web application
  • add the indexed column
  • create a view that contains less of 5000 items (for example with where condition on created date)
  • from the central administration, reset the threshold value to 5000 on the current web application

In the case that you want to use the REST API on the list, remember that all fields that you need to apply $filter condition, need to defined as indexed column, otherwise you'll have the error "Internal server error".

See these links for more details

Published in SharePoint
Thursday, 05 July 2012 08:26

Delete field and all its references

A simple way to delete a Field from all content types, lists and clean all its references, is to run this script (the attachment is at the end of the article):

Show/Hidden bash code

View source
param([string]$serverUrl = $(Throw "You have to specify the serverUrl"),[string]$fieldName = $(Throw "You have to specify the InternalName field to be delete"))
# Load SharePoint PowerShell
$snapin = get-pssnapin | `
    where { $_.Name -eq “Microsoft.SharePoint.PowerShell” }
if($snapin -eq $null)  {
  Add-PsSnapin Microsoft.SharePoint.PowerShell
# Delete Field
Write-Output “Start removing field:” $fieldName 
$site = Get-SPSite $serverUrl
$web = $site.RootWeb
#Delete field from all content types
foreach($ct in $web.ContentTypes) {
    $fieldInUse = $ct.FieldLinks | Where {$_.Name -eq $fieldName }
    if($fieldInUse) {
        Write-Output “Remove field from CType:” $ct.Name
#Delete column from all lists in all sites of a site collection
$site | Get-SPWeb -Limit all | ForEach-Object {
   #Specify list which contains the column
    $numberOfLists = $_.Lists.Count
    for($i=0; $i -lt $_.Lists.Count ; $i++) {
        $list = $_.Lists[$i]
        #Specify column to be deleted
        if($list.Fields.ContainsFieldWithStaticName($fieldName)) {
            $fieldInList = $list.Fields.GetFieldByInternalName($fieldName)
            if($fieldInList) {
                Write-Output “Delete column from ” $list.Title ” list on:” $_.URL
             #Allow column to be deleted
             $fieldInList.AllowDeletion = $true
             #Delete the column
             #Update the list
# Remove the field itself
if($web.Fields.ContainsFieldWithStaticName($fieldName)) {
    Write-Output “Remove field:” $fieldName
    $field.AllowDeletion = $TRUE

To run the script, open powershell and write this command from the same script folder:

DeleteFieldAndAllReferences.ps1 -serverUrl -fieldName 'InternalFieldNameToBeDeleted'

Published in SharePoint