I’m trying to create a C# program using a Sharepoint Web Service reference that will accept user input every day and update a list. The data is potentially different every day so I need a reliable way to delete every item in the list before the update statement is sent for the new items.
The only way to delete an entry is by referencing its item ID number. I tried just creating a loop that’ll generate a delete statement that blankets ID 1-50, but since the list always increments that only works until 50 items go through. In my Googling I’ve found that the only way to reset a list to ID 1 is to delete it and recreate it. Unfortunately, if I do that, it’ll have a different GUID and my program will no longer be able to call it the next time it’s run.
Is there some solution I’m not seeing here?
You can’t re-create a list with a specified GUID.
But from your comment you’re off on a tangent here if the only reason you need to reset the ID to 1 is to help out with your empty list operation.
The XML returned from GetListItems() is in the format
So to ‘reliably’ loop through that is something like (not tested but you get the idea)
See this MSDN article for more inspiration
Further – to delete all these records with one call you can do a batch update by sending UpdateListItems by building up an XML fragment something like this in the for loop above.
Notes
sequential +1 for each batch method.
the ID’s of the list you found in the
for loop above.