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,
this is the code with which to retrieve the template, but when I want to create the library generates an error message.
“Input string was not in a correct format”
Code Javascript add List
this.templateTestLibrary = this.colltemplate.get_item(7);
var listCreationInfo = new SP.ListCreationInformation();
listCreationInfo.set_title(‘Test_Biblioteca’);
listCreationInfo.set_templateType(this.colltemplate.get_item(7).get_featureId()); //
this.list = web.get_lists().add(listCreationInfo);
clientContext.load(list);
clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
XML , Request – /vti_bin/client.svc
<Request xmlns=”http://schemas.microsoft.com/sharepoint/clientquery/2009″ SchemaVersion=”15.0.0.0″ LibraryVersion=”16.0.0.0″ ApplicationName=”Javascript Library”>
<Actions>
<ObjectPath Id=”11″ ObjectPathId=”10″ />
<ObjectPath Id=”13″ ObjectPathId=”12″ />
<ObjectIdentityQuery Id=”14″ ObjectPathId=”12″ />
<Query Id=”15″ ObjectPathId=”12″>
<Query SelectAllProperties=”true”>
<Properties>
<Property Name=”Description” ScalarProperty=”true” />
<Property Name=”TemplateFeatureId” ScalarProperty=”true” />
<Property Name=”Title” ScalarProperty=”true” />
</Properties>
</Query>
</Query>
</Actions>
<ObjectPaths>
<Property Id=”10″ ParentId=”4″ Name=”Lists” />
<Method Id=”12″ ParentId=”10″ Name=”Add”>
<Parameters>
<Parameter TypeId=”{e247b7fc-095e-4ea4-a4c9-c5d373723d8c}”>
<Property Name=”CustomSchemaXml” Type=”Null” />
<Property Name=”DataSourceProperties” Type=”Null” />
<Property Name=”Description” Type=”Null” />
<Property Name=”DocumentTemplateType” Type=”Number”>0</Property>
<Property Name=”QuickLaunchOption” Type=”Number”>0</Property>
<Property Name=”TemplateFeatureId” Type=”Null” />
<Property Name=”TemplateType” Type=”Guid”>{00bfea71-e717-4e80-aa17-d0c71b360101}</Property>
<Property Name=”Title” Type=”String”>Test_Biblioteca</Property>
<Property Name=”Url” Type=”Null” />
</Parameter>
</Parameters>
</Method>
<Property Id=”4″ ParentId=”0″ Name=”Web” />
<StaticProperty Id=”0″ TypeId=”{3747adcd-a3c3-41b9-bfab-4a64dd2f1e0a}” Name=”Current” />
</ObjectPaths>
</Request>
any ideas?, thanks for the help