I am trying to add a folder to the document set but the folder got created at the parent document library. Can somebody help me to find out what am i doing wrong ?
Following is the code:
var createFolder = function(context, list, foldername) {
var itemCreateInfo = new SP.ListItemCreationInformation();
itemCreateInfo.set_underlyingObjectType(SP.FileSystemObjectType.folder);
itemCreateInfo.set_leafName(foldername);
itemCreateInfo.set_folderUrl = String.format("/Lists/{0}/{1}", "Documents", "Custom");
var listItem = list.addItem(itemCreateInfo);
listItem.set_item('Title', foldername);
listItem.update();
context.load(listItem);
context.load(list);
context.executeQueryAsync(
Function.createDelegate(this, successHandler()),
Function.createDelegate(this, errorHandler));
function successHandler() { console.log('Success'); }
function errorHandler() { alert("Request failed: message = " + arguments[1].get_message()); }
}
"Documents" is the document library and "Custom" is the document set in above code.
Thanks.