I want to navigate into a folder in SharePoint and create there a File. I can already create a file on the "root" folder of a selected list.
However I can't "switch" into a specific folder (document set) which is in the root folder.
clientContext = new SP.ClientContext.get_current();
oWebsite = clientContext.get_web();
oList = oWebsite.get_lists().getByTitle("Documents");
folderPath = getParameterByName('RootFolder');
var folderPathArray = folderPath.split('/');
var documentSetName = folderPathArray[folderPathArray.length -1];
var encodedFolderPath = [];
folderPathArray.forEach(function (element) {
encodedFolderPath.push(encodeURIComponent(element));
});
folderPath = encodedFolderPath.join("/");
fileCreateInfo = new SP.FileCreationInformation();
fileCreateInfo.set_url(folderPath + title + ".aspx");
fileCreateInfo.set_content(new SP.Base64EncodedByteArray());
fileContent = "helloworld";
for (var i = 0; i < fileContent.length; i++) {
fileCreateInfo.get_content().append(fileContent.charCodeAt(i));
}
// how to call get_files() in a document set so I can use the add method like below?
this.newFile = oList.get_rootFolder().get_files().add(fileCreateInfo);
var realFolder = oList.get_rootFolder().getByTitle("Special Folder");
clientContext.load(this.newFile);
clientContext.executeQueryAsync(onsuccess, onfailedownError');