I would like to create a list from custom template already available in the site. I tried following code -
this.result = SP.ClientContext.get_current().get_site().getCustomListTemplates(SP.ClientContext.get_current().get_web());
SP.ClientContext.get_current().load(this.result);
function retrieveTemplates_fail() { }
function retrieveTemplates_success()
{
var en = this.result.getEnumerator();
while (en.moveNext())
{
var item = en.get_current();
if (item.get_name() === 'Template - Review Access')
{
var listCreationInfo = new SP.ListCreationInformation();
listCreationInfo.set_title('testfromtemplate1');
//alert(item.get_featureId());
//alert(item.get_listTemplateTypeKind());
listCreationInfo.set_templateFeatureId('{00bfea71-de22-43b2-a848-c05709900100}');
listCreationInfo.set_templateType('100');
SP.ClientContext.get_current().get_web().get_lists().add(listCreationInfo);
function createList_fail() { alert('fail') };
function createList_success() { alert('success') };
SP.ClientContext.get_current().executeQueryAsync(
Function.createDelegate(this, createList_success),
Function.createDelegate(this, createList_fail)
);
}
}
}
SP.ClientContext.get_current().executeQueryAsync(
Function.createDelegate(this, retrieveTemplates_success),
Function.createDelegate(this, retrieveTemplates_fail)
);
On executing the code I can only create list - Custom list with out the columns available in list template.
Can someone guide whats wrong in the code or provide any new code. Is json code available ?