How to create list from list template in Host Web?

I have created SharePoint hosted app and some how I managed to copy the list template file to host web's list template gallery . Now I want create list from that list template from my app web to the host web

1 Answer 1


(JSOM) : add the following script to create the list.

//Add jquery version correctly   
<script type="text/javascript" src="../Scripts/jquery-1.7.1.min.js"></script>

<script type="text/javascript" src="https://ajax.aspnetcdn.com/ajax/4.0/1/MicrosoftAjax.js"></script>
<script type="text/javascript" src="/_layouts/15/init.js"></script>
<script type="text/javascript" src="/_layouts/15/sp.runtime.js"></script>
<script type="text/javascript" src="/_layouts/15/sp.js"></script>

<script type="text/ecmascript">

    function createList() {
        var clientContext = new SP.ClientContext.get_current();
        var oWebsite = clientContext.get_web();

        var listCreationInfo = new SP.ListCreationInformation();
        listCreationInfo.set_title('CustomList'); // list name
        listCreationInfo.set_description('description'); // list description
        listCreationInfo.set_templateType(SP.ListTemplateType.genericList); //list type


            Function.createDelegate(this, this.onQuerySucceeded),// when success
            Function.createDelegate(this, this.onQueryFailed) // when failed
    function onQuerySucceeded() {
        alert("List Created");

    function onQueryFailed(sender, args) {
        alert("List Failed");


Ref Create a SharePoint 2013 List Using JSOM (ECMAScript Client Object Model)

(CSOM) : Below is the code in which you have to send parameter :

  • strSiteURL: Site URL on which you have to create List using template.

  • strTemplateName: Template name of which you have to create list

  • strListName: Name of the list.

    public void CreateListFromTemplate(string strSiteURL,string  strTemplateName,string strListName) {
    using (SPSite oSPsite = new SPSite(strDestinationURL))
    oSPsite.AllowUnsafeUpdates = true;
    using (SPWeb oSPWeb = oSPsite.OpenWeb())
    oSPWeb.AllowUnsafeUpdates = true;
    SPListTemplateCollection lstTemp = oSPsite.GetCustomListTemplates(oSPWeb);
    SPListTemplate template = lstTemp[strTemplateName];
    oSPWeb.Lists.Add(txtListName.Text, "Description", template);
    Guid listId = oSPWeb.Lists.Add(txtListName.Text, "Description", template);
    SPList mylist = oSPWeb.Lists[listId];
    mylist.OnQuickLaunch = false;
    oSPWeb.AllowUnsafeUpdates = false;
    oSPsite.AllowUnsafeUpdates = false;

Ref : Create List from Custom List Template Programmatically in SharePoint

  • What you have provided is done using CSOM, I want do it in JSOM Jul 27, 2016 at 13:15
  • check this codeproject.com/Articles/560049/… Jul 27, 2016 at 13:35
  • Appriciate your efforts but I want to create list using existing template from list template gallery Jul 27, 2016 at 13:51
  • at this line you can specify your template SPListTemplate template = lstTemp[strTemplateName]; Jul 27, 2016 at 14:20
  • The C# code is actually using server object model, not client.
    – wjervis
    May 3, 2017 at 12:31

Your Answer

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

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