Automatically declaring items as records causes duplicates in SharePoint Server

Original KB number:   2905419

Symptoms

You create a site collection by using the Records Center template in Microsoft SharePoint Server 2010 or Microsoft SharePoint Server 2013. When you update new content to the default Drop Off library in this site collection, you receive following error message:

Microsoft SharePoint Server 2010: Error
This item cannot be deleted, moved, or renamed because it is either on hold or is a record which blocks deletion.

Microsoft SharePoint Server 2013:
Sorry, something went wrong.
This item cannot be deleted, moved, or renamed because it is either on hold or is a record which blocks deletion.

The uploaded item is automatically declared a record and is copied to one of the destination libraries as per the configuration of the content organizer rules. You also see this error if you try to delete these copied items from the respective Drop Off or record library.

The declaration status of this item doesn't change even if you try to undeclare it in Compliance Details section. If you edit this item in the Drop Off library even without any changes and submit, a new duplicate item is created in the record library. The name of this duplicate item is appended with a unique autogenerated ID.

If you disable the automatic declaration of items and enable manual declaration of items, the items from the Drop off library can be deleted. However, the items from the record library remain as duplicates that cannot be deleted.

Cause

This occurs because the move operation of an item from one library to another is completed in two phases. First it is copied from the source to the destination, and then it is deleted from the source. In this situation, the source is the Drop Off library, and it is declaring items as records as soon as they are uploaded. As the items are declared as records in a Drop Off library, they cannot be deleted. After the upload, the content organizer rules run to move the item to its destination. This finishes the copy operation successfully and the item is available at the destination. However, because it is declared, the item cannot be deleted in the Drop Off library. If you try to delete this item, it will cause the previously mentioned error to occur.

Editing the item properties causes the organizer rules to run again, repeating the procedure. This time, because the document is already present in the destination, the item name is suffixed with a unique ID.

When the Drop Off library is changed to allow for manual declaration of records, such items can be deleted after you undeclare them. When an item in a record library is changed, the item cannot be deleted, because the library does not change the declaration state of this item.

Resolution

Step 1: Fix Drop Off library duplicates

Update the Drop Off library so that it doesn't automatically declare items as records. The Drop Off library is used to drop the documents into one location that can be subject to many content organizer rules.

This makes sure that any new items uploaded to the Drop Off library do not cause duplication or throw an error. Enable manual declaration of records in the Drop Off library so that you can delete existing documents after you undeclare them and clean up the Drop Off library.

Step 2 Fix Record library duplicates

To fix the existing duplicates in the record library, follow these steps:

  1. Delete the event receiver that runs during the item delete action.
  2. Delete the duplicate records.
  3. Add the event receiver back.

The following section lists the steps in detail:

Important

Deleting the event receiver that runs during the delete attempt will enable deletion of any document. This includes any legitimate documents that should not be deleted. Test these steps in a test environment first. Take extreme precaution by making sure that the site is unavailable to users during this exercise so that users do not delete any other documents.

  1. In SharePoint Management Shell, run the following script to and list all the event receivers:

    $problemweb = Get-SPWeb http://<Your Site Collection>
    $problemlist = $problemweb.Lists["<Record Library Name>"]
    $problemlist.EventReceivers | select type, name
    

    Note

    You must replace <YourSiteCollection> and <Rocrdr Listbrayt name> with the correct value.

    In this output, calculate the position of the ItemDeleting event receiver type by starting from the top as position number 0 while incrementing the sequence of the next event receiver.

    For example, in the following output, the ItemDeleting event receiver is in second position in the array. So, the position number is 1 as arrays start with 0:

    Type Name
    ---- ----
    ItemUpdating ECM_RecordEventReceiver
    ItemDeleting ECM_RecordEventReceiver
    ItemFileMoving ECM_RecordEventReceiver
    ItemAdded Document ID Generator
    ItemAdded ECM_RecordEventReceiver
    ItemUpdated Document ID Generator
    ItemUpdated ECM_RecordEventReceiver
    ItemCheckedIn Document ID Generator
    ItemCheckedIn ECM_RecordEventReceiver
    ItemUncheckedOut Document ID Generator
    
  2. Make sure that the array position points to the ItemDeleting event receiver:

    $problemev = $problemlist.EventReceivers[Position of the "ItemDeleting" event receiver]
    

    For example:

    $problemev = $problemlist.EventReceivers[1]
    
  3. Delete the ItemDeleting event receiver:

    $problemev.Delete()
    
  4. Update the list:

    $problemlist.update()
    
  5. Remove the duplicates from the record library by using the browser.

  6. Run the following script to re-create the ItemDeleting event receiver:

    $problemevadded = $problemlist.EventReceivers.Add([Microsoft.SharePoint.SPEventReceiverType]::ItemDeleting,"Microsoft.Office.Policy, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c","Microsoft.Office.RecordsManagement.Internal.HoldEventReceiver")
    $problemlist.update()
    

More information

The event receiver ItemDeleting is of type SPEventReceiver. Supplying the receiverType, Assembly and className by using this method enables you to create the event receiver.