I need to create a Document Library and assign it columns with Javascript.
I've been searching around and I found the SP.ListCreationInformation documentation. Here is my code so far:
function createDocLibrary() {
var ctx = new SP.ClientContext.get_current();
var web = ctx.get_web();
var lci = new SP.ListCreationInformation ();
lci.set_title('My Custom Title');
lci.set_templateType(101);
this.oList = web.get_lists().add(lci);
ctx.load(oList);
ctx.executeQueryAsync(Function.createDelegate(this, this.newPBDLSuccess), Function.createDelegate(this, this.newPBDLFail));
}
function newPBDLSuccess() {
alert('success');
}
function newPBFail() {
alert('fail');
}
I can create the document library (thanks @Dylan Cristy for catching my mistake - I updated the code on this post), but am stuck on how to create the libraries columns with javascript.
Also, I'm using ExecuteOrDelayUntilScriptLoaded(createDocLibrary, "sp.js"); to ensure sp.js is loaded first.
Does anyone have a working example of creating a Document Library (or list) and setting its columns with javascript?
ListCreationInformation
(which you mention above your code block, and link to), but in your code you apparently are usingListItemCreationInformation
. Reference here: msdn.microsoft.com/en-us/library/… – Dylan Cristy Jul 8 '13 at 18:00