Tag: javascript

Creating OneNote notebooks in SharePoint via JSOM

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_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");

//send the request
 //created successfully, do stuff if needed 
 //something went wrong, do stuff if needed

Flash/JavaScript Video not working in SharePoint


We just ran into a funny issue with playing videos in SharePoint. We’re using tje JavaScript library flowplayer to play video files on our company intranet with the help of Flash, as I mentioned and demoed e.g. here and here. What we wanted to do next is to provide this functionality also on other servers (not just Asia Pacific, but globally). Besides flowplayer, we also looked at JW Player as an alternative, which uses a similar method of playing videos.



What now happened was that the videos were playing perfectly fine in our Asia Pacific intranet, but nowhere else. Interestingly, there were no JavaScript errors, and the library seemed to do what it should. There just wasn’t any video playing at all, we saw either a white or a black box, nothing else.



After lots of troubleshooting and testing we finally discovered the issue and the solution. The web application that hosts our Asia Pacific intranet had its Browser File Handling settings set to Permissive, while the other servers and web applications had it set to strict. After changing that, the video worked everywhere.
Note: This change affects not only the video files, but of course all files in your environment (PDF, Office, …). So before changing it, make sure that it doesn’t introduce any unwanted behaviour

Here are the steps to get there:
Open Central Admininistration -> Go to Manage web applications -> Select the corresponding web application and  select General Settings from the Ribbon -> select General Settings again -> Change Browser File Handling from Strict to Permissive


SharePoint Saturday India Online: Connecting Office 365 and Windows 8 HTML/JavaScript Apps

At the recent SharePoint Saturday India Online, I was presenting on the topic “Connecting Office 365 and Windows 8 HTML/JavaScript Apps”. The sessions was all about how to get started with developing Windows 8 apps and including data from Office 365 in them, including the very important “how to authenticate against Office 365”. As promised, you can find the source code from my proof of concept app (as mentioned during the presentation there’s still lots missing!), the presentation itself, as well as any additional important links


The Code

The Visual Studio project can be found here: Office 365 & Windows 8 - Sample App (276).
Once again, this is not a full app, but rather a proof of concept. There are many things missing (exception handling, splash screen, resume/standby handling, data caching, login management, …) which I leave up to you to implement. Have fun extending the code, correcting it, and making it better!


The Presentation

View it on slideshare


The Links

Setting up your environment

Download Windows 8 & Visual Studio 2012 Express:


Wictor Wilen’s blog post “How to do active authentication to Office 365 and SharePoint Online”

Luc Stakenborg’s blog post “Remote authentication in SharePoint Online”

Windows 8 App development

Create your first Metro style app using JavaScript

Creating Windows Runtime Components in C# and Visual Basic

 Additional Tools

SPServices (create your queries here and watch the requests with Fiddler to get proper SOAP envelopes if you don’t want to write them yourself)

Fiddler Web Debugger