Most probably it occurs since List.TemplateType
and ListTemplateFeatureId
properties for a out-of-the-box Custom List (Feature ID:00BFEA71-DE22-43B2-A848-C05709900100
) are passed instead of your custom List.
How to determine List TemplateFeatureId
and TemplateType
properties
TemplateType:
the list of available List template types could be found on this pageTemplateFeatureId
: to determineFeatureId
property, you could save your list as a template, then go to List Template Gallery page (/_catalogs/lt/Forms/AllItems.aspx
) and find the Feature Id value of the corresponding list.
How to create a List based on custom list template via JSOM
The following example demonstrates how to create custom Tasks list:
var context = SP.ClientContext.get_current();
var web = context.get_web();
var listInfo = new SP.ListCreationInformation();
listInfo.set_title('Project Tasks');
listInfo.set_description('Project Tasks');
listInfo.set_templateType(SP.ListTemplateType.tasksWithTimelineAndHierarchy);
listInfo.set_templateFeatureId('F9CE21F8-F437-4F7E-8BC6-946378C850F0''<custom tasks feature id>');
var list = web.get_lists().add(listInfo);
context.executeQueryAsync(
function () {
console.log(String.format('List {0} has been created successfully',list.get_title()));
},
function (sender, args) {
console.log(args.get_message());
}
);