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).
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.
To resolve above issue we have found one solution which was described below.
- Store all item ID into a collection or array.
- Sort above collection in ascending order so that lowest id should copy first.
- Copy first item from source list to your destination list.
- Check item ID of source list is equal to Item ID of destination list.
- If same then continue with second item.
- 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
- You can get step by step process of Retain Item ID from this link.
About the Client:
Client: SharePoint Solution Provider
Technologies Used: SharePoint, Office 365, Client Object Model