Duplicate a SharePoint List

Is it easy to duplicate SharePoint list code?

+3
source share
1 answer

Judging by the SharePoint tag, I assume that you want to ask: "How to copy a SharePoint list (SPList) programmatically?"
Without testing it (or even trying to compile it), I would do something like:

SPWeb web; /* add code to initialize to current web */
SPList sourceList = web.Lists["nameOfSourceList"];
sourceList.SaveAsTemplate("templateFNM.stp", "tempList", "tempListDescription", 
                          true /* include list content */);
SPListTemplate template = web.ListTemplates["tempList"];
web.Lists.Add("newListName", "newListDescription", template);
web.Update();
SPList newList = web.Lists["newListName"];

In addition, here is a link to a blog post that achieves the same use of web applications.

And finally, a tip: you will get better search results if you use "programmatically" instead of "code wise".

Hope this helps.

+5
source

Source: https://habr.com/ru/post/1699284/


All Articles