SharePoint – programmatically add list items and set ID


I need to create list items in sharepoint and also set the ID field too. However I get an error when trying to do this as it's read only. Is there a way I can set the ID column value when programmatically creating items in a sharepoint list?

As a side note the reason I need to do this is because I need to add items to two sharepoint lists where the second uses the id column of the first as a lookup.



Best Solution

As you already mentioned, the ID of a list item is marked as read only. And I think there is no way to work around that.

I think the easiest solution would be to add a new column to the second list which uses the first ID column for lookup. Then the items in list one and two still have two different IDs but you can reference them by the second column in list two.

Related Question