This article has been published originally in German on the 1stQuad company blog.
With server-side code, it is fairly easy to create OneNote notebooks in SharePoint. In this article, I want to explain briefly how to achieve this with the JavaScript Object Model (JSOM).
In a current project, one of the requirements was to create OneNote notebooks automatically in Office 365. This had to happen either with out-of-the-box functionality or via API calls (REST or JSOM). After a few tries, it turned out that doing it via JSOM seems to be the best (and only?) option.
Generally speaking, a OneNote notebook in SharePoint is nothing else but a folder that is handled in a very specific way. With server-side code, you can “turn” a regular folder into a OneNote notebook by setting the ProgId property of the corresponding SPListItem to “OneNote.Notebook”. As you can’t access ProgId via JSOM, a different way to implement this functionality has to be found. Luckily, you can achieve the same thing by setting the property “HTML File Type” of a folder.
The following code snippet shows a short example
//common variables var context=SP.ClientContext.get_current(); var web=context.get_web(); var lists=web.get_lists(); var list=lists.getByTitle("Documents"); //create a new folder var itemCreationInfo=new SP.ListItemCreationInformation(); itemCreationInfo.set_underlyingObjectType(SP.FileSystemObjectType.folder); itemCreationInfo.set_leafName("Name of the new Notebook"); //modify the folder to convert it into a OneNote notebook var onenoteNotebook=list.addItem(itemCreationInfo); onenoteNotebook.set_item("HTML_x0020_File_x0020_Type" ,"OneNote.Notebook"); onenoteNotebook.update(); //send the request context.load(onenoteNotebook); context.executeQueryAsync(function(){ //created successfully, do stuff if needed }, function(sender,args){ //something went wrong, do stuff if needed });
new blog post: Creating OneNote notebooks in SharePoint via JSOM http://t.co/UN3ncPZ07v #office365
RT @modery: new blog post: Creating OneNote notebooks in SharePoint via JSOM http://t.co/UN3ncPZ07v #office365
RT @modery: new blog post: Creating OneNote notebooks in SharePoint via JSOM http://t.co/UN3ncPZ07v #office365
“@modery: new blog post: Creating OneNote notebooks in SharePoint via JSOM http://t.co/JUYRWylk0r #office365″ -> Excellent!
RT @adamtoth: “@modery: new blog post: Creating OneNote notebooks in SharePoint via JSOM http://t.co/JUYRWylk0r #office365″ -> Excellent!
RT @nikxpatel: “@modery: new blog post: Creating OneNote notebooks in SharePoint via JSOM http://t.co/vzJUeXuCxf #office365″
RT @nikxpatel: “@modery: new blog post: Creating OneNote notebooks in SharePoint via JSOM http://t.co/vzJUeXuCxf #office365″
RT @nikxpatel: “@modery: new blog post: Creating OneNote notebooks in SharePoint via JSOM http://t.co/vzJUeXuCxf #office365″
Creating OneNote notebooks in SharePoint via JSOM http://t.co/CQcCt6YgWG really excited to see what people do! nice job @modery
RT @jthake: Creating OneNote notebooks in SharePoint via JSOM http://t.co/CQcCt6YgWG really excited to see what people do! nice job @modery
RT @jthake: Creating OneNote notebooks in SharePoint via JSOM http://t.co/CQcCt6YgWG really excited to see what people do! nice job @modery
RT @jthake: Creating OneNote notebooks in SharePoint via JSOM http://t.co/CQcCt6YgWG really excited to see what people do! nice job @modery
RT @jthake : “Creating OneNote notebooks in SharePoint via JSOM http://t.co/3Ui1asfyyj …” #OneNote #SharePoint
RT @jthake: Creating OneNote notebooks in SharePoint via JSOM http://t.co/CQcCt6YgWG really excited to see what people do! nice job @modery
RT @3Sharp: RT @modery “new blog post: Creating OneNote notebooks in SharePoint via JSOM http://t.co/g9KLgUOF9o #office365″
RT @jthake: Creating OneNote notebooks in SharePoint via JSOM http://t.co/CQcCt6YgWG really excited to see what people do! nice job @modery
Creating OneNote notebooks in SharePoint via JSOM | Office 365 MVP Rene Modery http://t.co/fTgFG762nJ
Wonder how far the work done to have OneNote intertwingle with SharePoint is the basis of the new APIs? @msonenote http://t.co/9Yda3Go0Ha
from the archive: Creating OneNote notebooks in SharePoint via JSOM http://t.co/t0aGunWANE #office365 #sharepoint
RT @modery: from the archive: Creating OneNote notebooks in SharePoint via JSOM http://t.co/t0aGunWANE #office365 #sharepoint
Creating OneNote notebooks in SharePoint via JSOM http://t.co/xw31gyrb1L