I'm trying to create a new item in my Entreprise Wiki
Pages
Document Library. It's associated with a News Content type. I was able to retrieve the SP.List
object (myList), the SP.ContentType
object (myContentType) but now I just need to match both. Here is the code that I've tryed.
var listItemInfo = new SP.ListItemCreationInformation();
listItemInfo.set_leafName('Test');
var listItem = myList.addItem(listItemInfo);
listItem.set_item('Title', 'MyTest');
listItem.set_item('ContentTypeId', myContentType.get_id());
listItem.update();
context.load(myList);
context.executeQueryAsync();
And I have this error :
To add an item to a document library, use the SPFileCollection.Add()
Can someone give me some clue ? I don't have an actual file to upload. On the UI, I juste click the new document for my content type.