I am trying to add folders to a library using JSOM. I need to set the content type of the new library items, however I am not finding the documentation on how to do that anywhere.
var itemCreateInfo = new SP.ListItemCreationInformation(); itemCreateInfo.set_underlyingObjectType(SP.FileSystemObjectType.folder); itemCreateInfo.set_leafName("test3"); var oListItem = empLib.addItem(itemCreateInfo); oListItem["ContentTypeID"] = "Employee Folder"; oListItem.update();
This is the code that I have used so far, and it just adds an item of content type folder.
I use the 2nd and 3rd lines for 2 reasons:
- The content type I need inherits from folder
- Without those lines (just adding a standard item to the library), when trying to add items it gave me an error telling me to use
SPFileCollections.Add, which does not work.
I would greatly appreciate any insight on the subject.