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');});