Hi all,
I want to create a library from a template, the code that been testing it:
and this modifies the example below but I have not had any success, do not know how to associate a custom list.
thank you very much! for their help
Example :
function runCode() {
var clientContext = new SP.ClientContext.get_current();
if (clientContext != undefined && clientContext != null) {
var web = clientContext.get_web();
var listTemplates = web.get_listTemplates();
var templateTestLibrary = listTemplates.getByName(‘TemplateLibrary_v23’);
var listCreationInfo = new SP.ListCreationInformation();
listCreationInfo.set_title(‘test creation library’);
// listCreationInfo.set_templateType(SP.ListTemplateType.discussionBoard);
listCreationInfo.set_templateType(templateTestLibrary);
this.list = web.get_lists().add(listCreationInfo);
clientContext.load(list);
clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
}
}
function onQuerySucceeded() {
var result = ‘ Added Discussion Board: ‘ + this.list.get_title();
alert(result);
}
function onQueryFailed(sender, args) {
alert(‘Request failed. ‘ + args.get_message() + ‘\n’ + args.get_stackTrace());
}
Hello all,
Thanks Sigitas for your reply, But I have not been successful,
If I assign this parameter error occurs and if I assign eg ‘101’ Document Library.
Create the library, but does not use the template but the standard of Documents
listCreationInfo.set_title(‘Test_Biblioteca’);
listCreationInfo.set_description(‘prueba’);
// If you do not assign a value according to this list fails me:
// http://msdn.microsoft.com/enus/library/lists.lists.addlist (v = office.12). Aspx
listCreationInfo.set_templateType(‘101’); //
listCreationInfo.set_templateFeatureId(this.colltemplate.get_item(7).get_featureId());
this.list = web.get_lists().add(listCreationInfo);
clientContext.load(list);
thanks for the help,