SharePoint 2016, 2013 , 2010 , 2007 Create list item with existing ID
Now
i was in a really tricky scenario where a master record had been deleted by someone which was referenced
using code in numerous places. Changing the code would be a nightmare.
Now
the easiest solution which will come to everyones mind is to add the list item
with those possible values again. But it would not retain the ID value which
was used in the code.Let me give you an example to clarify the problem
statement
PROBLEM STATEMENT
There is a “status” master list with the following values and the
third list item is deleted.
We want the 3rd list item with ID=3 to be restored even when it is deleted from recycle bin as in the code the ID column is used to reference the status.
We want the 3rd list item with ID=3 to be restored even when it is deleted from recycle bin as in the code the ID column is used to reference the status.
Status
|
ID
|
Approved
|
1
|
Rejected
|
2
|
In
Draft
|
4
|
SOLUTION:
Now usually the answers would be
- Restore it from recycle bin (almost 3 months have passed and it has been deleted from recycle bin as well)
- Delete the list and recreate the list with fresh entries (Break referential integrity of lists where the column from this list is looked up i.e lookup )
- It cannot be done.ID is auto increment column (Sad to head but its true)
So, last option would be to change the code L
This would result in enormous effort of code changing.
But wait if even you face similar scenario and
have lesser amount of records (say 10-15
records) which have to be recovered then there is a savior
SITE MANAGER
Follow below steps to recover your item
- Create a replica of the list where the item is to be recovered
- Add all the items in the order required.
- Navigate to site manager using below url
- http://<web level url>/_layouts/sitemanager.aspx
- Select the replica list in left navigation then list items will appear in right pane.
- Select the list item from replica list and select Actions >> Copy
- Then in the copy dialog select the original list where the item was deleted.
- Done
Note: This
method can be used only when the item is deleted from recycle bin as well.If
the item of same is present in recycle then it would not recreate with same ID.
very nice...
ReplyDeleteThanks Unknown
Delete