1

I am creating SharePoint list using Custom list template using javascript. and I am able to create new list successfully. but this new list is not using custom list template. it has only Title column. My code is executing successfully but it does not have my custom columns which were available in custom list template. I even tried to set listCreationInfo.set_listTemplate=myCustomtemplate, but getting error on this line as 'Object does not support set_listTemplate method'

I know this question has been asked multiple times, but I haven't got any answer.

var rootCTX = new SP.ClientContext.get_current();
    var Audit = rootCTX.get_web();
    var listTemplateCollection = rootCTX.get_site().getCustomListTemplates(Audit);

    var currentAuditListTemplate=listTemplateCollection.getByName('AuditSubmissionListTemplate');


    rootCTX.load(currentAuditListTemplate);
    rootCTX.executeQueryAsync(function(){
        console.log('template found');
        var auditTitle=$(":input[title='Audit Title Required Field']").val();   
        var listCreationInfo = new SP.ListCreationInformation();
        listCreationInfo.set_title(auditTitle);
        listCreationInfo.set_listTemplate(currentAuditListTemplate);
        listCreationInfo.set_templateFeatureId(currentAuditListTemplate.get_featureId());

        listCreationInfo.set_templateType(currentAuditListTemplate.get_listTemplateTypeKind());

        var newList = EDMSAudit.get_lists().add(listCreationInfo);
        rootCTX.load(newList);
        rootCTX.executeQueryAsync(function(){       
                alert('List created');
        },function(){
                alert('Error');});
2
  • You connect library sp.js?
    – Fox
    Aug 10, 2018 at 6:48
  • yes.looks like Sharepoint 2013 ListCreationInformation does not support ListTemplate property. I read on other sites that its not possible in COM to create list on basis of Custom list template. we have to use customSchemaXML. let me know if you have any idea Aug 10, 2018 at 6:53

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.