none
How to create SPList with custom template using csom?

    Question

  • 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


    • Edited by Anil ROCK Monday, June 27, 2016 7:03 AM
    Thursday, June 9, 2016 10:30 AM