RETAIN ITEM ID WHILE COPYING LIST

Executive Summary

We have developed a SharePoint Content Migration Tool using Client Side Object Model which has various options including copy of lists from one site collection or sub site (from any SP version (SP 2010, SP 2013, SP 2016) to another site collection or sub site presents in another farm or same farm (to any SP version (SP 2010, SP 2013, SP 2016).

ISSUE

For copying list our client has included various options. Among them one option was to retain item id. If one item in source list has id 5 then in destination list id of item should be 5.

As we know ID field of list is read-only, auto generated and auto incremented field. Whenever an item has added to list ID of new item assigned automatically and it is greater than 1 of previously created item.

SOLUTION

To resolve above issue we have found one solution which was described below.

  1. Store all item ID into a collection or array.
  2. Sort above collection in ascending order so that lowest id should copy first.
  3. Copy first item from source list to your destination list.
  4. Check item ID of source list is equal to Item ID of destination list.
  5. If same then continue with second item.
  6. If ID is not same then delete exactly N no of items where N is the difference between source item id and destination item id. If Item ID of destination list item is 5 and ID of source list item is 2.Then N= (5-2)-1
  7. You can get step by step process of Retain Item ID from this link.

About the Client:
Client: SharePoint Solution Provider
Location: USA
Industry: IT
Technologies Used: SharePoint, Office 365, Client Object Model

Leave a Reply

Your email address will not be published. Required fields are marked *