i have a list in which i have 20 items,i have got the requirement that new list items id should start from 500,instead from 21
i have used below code to add new item to list and update listitemid with 500 it worked fine,but when i try to add new item from the UI(List/newitem) the ID value is 21 not 501Please letme know is their any way to start list item id from specific number .
code which i am using to update list item id
web.AllowUnsafeUpdates = true; site.AllowUnsafeUpdates = true; SPList list = web.Lists.TryGetList("test"); list.Fields[SPBuiltInFieldId.ID].ReadOnlyField = false; list.Fields[SPBuiltInFieldId.ID].Update(); list.Update(); SPListItem item = list.AddItem(); item["Title"] = "This item Id's is not auto-generated by SharePoint, it is explicitly specified"; item[SPBuiltInFieldId.ID] = 500; item.Update(); list.Fields[SPBuiltInFieldId.ID].ReadOnlyField = true; list.Update();
i cant use event receivers to set list item id on ItemAdded or itemadding
i cant update in Database
- Edited by suchithraj Tuesday, July 23, 2013 1:24 PM
When I've encountered this requirement in the past, the common solution has been to run a script to create and delete items until the ID has incremented to the desired number. That said, you might be better off using a different field than SharePoint's item ID field, since it can't be displayed in out-of-the-box forms and alerts. You could use a calculated column as Prasath C suggested, or use a SharePoint Designer workflow to copy the ID (plus x) to a normal text or number field whenever items are added/updated.