Quantcast
Channel: Microsoft Online: SharePoint Online forum
Viewing all articles
Browse latest Browse all 10096

How to create SPList using costom template using csom?

$
0
0

I create a list Template (.stp) file now i download it and uploaded it on other PWA server. Now i want to create SP List using csom by this STP file. IS it Possible using CSOM.

I use this code. List createted successfully. But not by MY custom Template. It created as default Custom List

using (ClientContext ctx = new ClientContext(WebURL))
{
    ctx.Credentials = new SharePointOnlineCredentials(UserName, Password);

    var web = ctx.Web;
    var templates = web.ListTemplates;
    ctx.Load(web, s => s.ListTemplates);
    ctx.ExecuteQuery();

    var archiveTemplate = templates.GetByName(ArchiveTemplate);

    ListCreationInformation lic = new ListCreationInformation();
    lic.Title = "New List";
    lic.TemplateFeatureId = archiveTemplate.FeatureId;
    lic.TemplateType = archiveTemplate.ListTemplateTypeKind;
    web.Lists.Add(lic);
    ctx.ExecuteQuery();

}


anil gangwar


Viewing all articles
Browse latest Browse all 10096

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>