6

I have been working on my site collection on test environment. and now i want to backup the site collection and restore it inside our live server. now the only issue i have faced in this process is how i can remove test items from our lists and reset the item Id to be equal to 1.

now i have a custom list inside our test environment that have the following customizations :-

  1. inside the AllItems.aspx list view and other list views i have edited the page, and i add some script editor web parts.
  2. also for each list view i added an advance search web part https://splistviewfilter.codeplex.com/releases .

so now i tried the following:-

  1. inside the test server i saved the list as template (without content).
  2. Remove the the list.
  3. Create a new list based on the template.

but the result i got is not what i was looking for , for the following main reason:-

  1. on the new list (which i create based on the template) all the customization i did on the list views; such as adding script editors, adding advance search web part have been lost.

so can anyone adivce if there is a more reliable way to reset my list data and keep all the customization i did inside the list views ? as seems saving a list as template will not preserve these kind of customization. so not sure if sharepoint support deleting all the list items, and start the items' index from 1? as it will not be accurate to simply delete all items on live , and then when a user create a new item , its ID will be for example 70 instead of 1!!

4
  • 1
    AFAIK there is no way to reset the ID counter to zero. If the number of views are less, you can manually add those webparts to view pages again.Put all the code of script editor webparts in a html file and refer it in the script editor web part
    – Unnie
    Dec 25, 2016 at 11:02
  • 1
    In other words: the ID is assigned by the Database layer, not SharePoint. So the only option is to create new Lists. You can change the database, but at that point Microsoft says you lost your warranty. Strictly speaking your business logic should not rely on those IDs at all.. they should just be A unique number Dec 25, 2016 at 12:07
  • @Danny'365CSI'Engelman i know that IDs do not have any business logic , and they only provide a way to uniquely identify the items nothing else.. so what you are trying to say that i can simply remove all the test items on live and start from there,, so when users create a new item on live then the item id might be 50 instead of 1 ,, but this should not be a problem..
    – John John
    Dec 26, 2016 at 2:29
  • If you have not built any business logic on those IDs where the first Item needs to be number 1 than it doesn't matter what the ID is. They serve the same purpose as GUIDs, only they are not Global (as in a unique value in this whole world), IDs only label Icons unique within One list. Actually ... every Item indeed gets a GUID, those IDs where just handy shorter notation. Dec 26, 2016 at 9:52

1 Answer 1

6

You can save the list as a template, then create it where you want. The updates on the list view won't be migrated, so what you can do is:

  • Open the first list in SharePoint Designer, by clicking on Lists and Libraries from the left menu in SharePoint Designer, then choose your list name.
  • From the views menu, choose your view name where you have the webparts added.

enter image description here

  • Your list view will be with the tag: <WebPartPages:XsltListViewWebPart , so you need to ignore it, as you already have the same in the migrated list, you're interested in other webparts, so you should be looking for <WebPartPages:ScriptEditorWebPart for example if you want to migrate the script editor webpart you have.

enter image description here

  • Copy the script editor, and open the migrated list, open the view, and paste it in the same location, and save.

This way you'll start from ID 1 as you have a new list instance, and you will have the wbeparts that were available on the page.

2
  • thanks for the answer, but my question was if i can simply reset my list without having to do all these steps...at the end i can import my web parts,, then i can export them inside the new list views...
    – John John
    Dec 26, 2016 at 2:25
  • The only way to do it is through database, which I haven't mentioned since it's not supported. Dec 26, 2016 at 2:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.