Everything is fine and working but I can't figure out how to create subfolders. There are two independent folders in two libraries in tutorial's example. What if I want to create one folder and subfolder in one library? E.g. /documents/folder/folder2.
const list = sp.web.lists.getByTitle('List');
const folderName = 'subfoldertitle';
const rootFolder = 'RootFolderTitle';
list.items.add({
Title: "temporaryName",
// The folder is created in a root, so create it first with a temp unique name
FileSystemObjectType: 1,
ContentTypeId: '0x0120'
// FileLeafRef unfortunately is ignored while creation
}).then(({ item }) => {
return item.update({
Title: folderName, // Rename the folder name
FileLeafRef: `${rootFolder}/${folderName}` // Move to a subfolder
});
}).then(console.log);
Replace RootFolderTitle with the name of the existing folder, and subfoldertitle with the desired subfolder name,
HI @mnikitina ,
I Would like to change the content type of the subfolder - I used @wflorczyk one-line code and created a folder in the Document library and a subfolder.
After it's created I need to update the subfolder with the "document set" Content-type.
I tried something like this and this won't work - console says item.update is not a function:
EDIT: And I also suffer from spaces, diacritics when trying to create a subfolder Do not you have any idea, how to encode/decore URI/URL?
I am trying to use this