16 September 2014

SharePoint Archive Solution - First Test Version

SP Archive for SharePoint logotype Today I welcome my mother, Kate, to the blog. She is responsible for the documentation and has just tried the first version of SP Archive, our new solution for SharePoint list archiving. Here she will tell you how it is used.
Kate Kalmstrom image
In an earlier blog post Peter wrote about his idea for a new solution that would archive SharePoint list items. Now the development is in its final phase, and the responsible developer, Jitu Patidar, has given me the first version to try and comment.

Backup or clean lists, libraries and calendars
SP Archive can be used with all kinds of lists – common lists but also libraries and calendars, because technically they are lists too. There is a checkbox for removal of the archived items, so SP Archive can be utilized either as a backup tool or for cleaning SharePoint lists without having to delete items when lists get too long.

SharePoint list limit
SharePoint has a list limit of 5000 items, and when you exceed it you will get problems. This is especially important to know if you are using Office 365 SharePoint Online, as it gives less control than other versions.

Because of this list limit you have to clean long lists either you want to do it or not. List items can often be archived with a workflow, and we have instructions on how to do that in the Tips section. However, with a workflow you can never decide in detail what should be archived. SP Archive gives you that possibility.

Choose site, list, field and item
SP Archive can send items from all kinds of SharePoint lists to a database, and you can select in detail exactly what to archive. The selection is made in several steps, but of course you don't have to make them all each time you archive:
  1. SharePoint site
  2. SharePoint list
  3. List fields to be included
  4. Items to be included
When you only use SP Archive for one list and always include the same list fields, you only have to make the fourth selection each time.

Settings and Archive dialogs
When you open SP Archive you will see a window with buttons for Archive and Settings. In the Settings dialog you can add or remove sites and lists. Once you have added a site or list to the settings, you can go to the Archive dialog and make your selection on what to archive.

Next time you will open the Archive dialog directly and only use the Settings when you want to change something that concerns the sites or lists.

My first impression of SP Archive is very good. It is easy to understand and use, and I think many organizations will find it helpful. Now I will make sure that everything is documented in time for the release, which should not be too far away.

Kate Kalmstrom
Sales and Marketing Business Solutions

11 September 2014

SharePoint Dynamic JavaScript Loading

SharePoint logotype Two weeks ago we published a blog post written by Lead Developer Jayant Rimza, where he described several solutions to the JavaScript problem that occurs with SharePoint 2013 Minimal Download Strategy.

That post has been so popular that we decided to create a SharePoint development entry in the Tips section. We hope our developers will contribute with more tips in the future. There you can find the SharePoint MDS and JavaScript article now, and the post below is also published in the Tips section. Once again Jayant "holds the pen", this time to explain how to best load JavaScript files in SharePoint:

Jayant Rimza photo When you are coding SharePoint using JavaScript, you need to load JavaScript files, and SharePoint offers multiple ways to do that. The major methods are to register the file on a page, to always load the file by using the SharePoint CustomAction in Module and to load the file on demand by using the Script on Demand function. This is valid for all SharePoint versions.

When a JavaScript file is registered on a page it is only available for that page, and this normally works good.
The problem comes when you are modifying the SharePoint ribbon using CustomAction and your CustomAction requires multiple JavaScript files. Then there are two loading methods available, to always load the files or to load them on demand.

 It is not good to always load JavaScript files. It will slow down the entire SharePoint performance, because it loads the JavaScript files on every SharePoint page and most often you do not need them all. You might only need them when a page is loaded or custom actions are executed.

JavaScript Always Loaded
Here I will first explain how to always load JavaScript or JavaScript code blocks. By using this method you can write check or condition when you want to load other JavaScript files.
JavaScript logo
From SharePoint CustomAction in Module you can register a JavaScript file and the file will be loaded in the entire SharePoint site. Only use this method when you really need to use the file all over SharePoint.

You can use this code to check condition and load other JavaScript files. You can use below code to register JavaScript in entire site:

    ScriptSrc="/mymodule/js/myjavascriptfile.js" Sequence="100">

ScriptSrc is the Path of the JavaScript file.
You can directly write a block of JavaScript using CustomAction of the SharePoint module.

    ScriptBlock="alert('script block loaded');"

 Script on Demand 

SharePoint provides a function to load JavaScript on Demand (“SP.SOD”). By Script on Demand you can load a JavaScript file by a SharePoint function, and it will provide a callback to execute code when the JavaScript file is loaded. This is a good approach to load JavaScript files and improve overall SharePoint performance. 

There are three steps to load a script on demand: first add “notify script” at the end of the dynamic load JavaScript file, then register the file and finally execute the load function.
  1. SP.SOD.notifyScriptLoadedAndExecuteWaitingJobs
    At the end of the file that is going to load dynamically you need to add this line of code:


    The Argument in the function "myjavascriptfile.js" is the key for that file. It does not have to be a file name, I only used the filename to avoid confusion. This key should be the same when you register the dynamic loading file and execute the load function.

    The key should be different for different JavaScript files, because internally SharePoint stores them in associate array with this key and value as path.
  2.  SP.SOD.registerSod
    This function is used to register the file for the Script on Demand that you want to load later.

    var thisUrl = "";

            if (_spPageContextInfo.webServerRelativeUrl !== "/") {
                thisUrl = _spPageContextInfo.webServerRelativeUrl;
    SP.SOD.registerSod("myjavascriptfile.js", thisUrl + "/mymodule/js/ myjavascriptfile.js");

    SP.SOD.registerSod accepts two arguments, the key for the file and its SharePoint path. This function registers the file in the SharePoint memory so that it will be loaded dynamically.
  3.  SP.SOD.executeFunc
    Use this function when you want to load the JavaScript file and execute the method.

    SP.SOD.executeFunc(“myjavascriptfile.js”, functionName, fn);
    function fn(){
            alert(“my JavaScript file loaded dynamically”);       

    This SharePoint function accepts three arguments: the key, the name of the function and the callback function that is executed after the file has been loaded. The key should be the same that you used in the method “SP.SOD.registerSOD”. (You can pass null into the second argument, because it is not mandatory. I always pass null in SP.SOD.executeFunc(“myjavascriptfile.js”, null, fn)

    Note that the callback function “fn” should not be in the file that is going to load. Instead it should be in the file or block that is loading the JavaScript file. After this callback function you can use all functions and variables of the dynamic loaded JavaScript File.

  • Do not always load all your files in SharePoint using CustomAction. It will slow down SharePoint performance.
  • You can load files when they are needed by SOD at event, button click, page load etc.
  • First add a line at the end of the JavaScript file that will notify SharePoint that the file is loaded completely: SP.SOD.notifyScriptLoadedAndExecuteWaitingJobs("key");
  • Register the file using the function SP.SOD.registerSod("key", “jspath");
  • Use executeFunc to load the file when needed. This method executes a callback function once the loading is done by SharePoint: SP.SOD.executeFunc(“key”, null, callback);
  • In all three steps to load the files dynamically, the key must be the same as for the JavaScript file.

Jayant Rimza
Lead Developer Business Solutions

10 September 2014

Microsoft Buys Swedish Minecraft Company?

Microsoft logo The big business news here in Sweden today  has been Microsoft's acquisition of the Swedish game company Mojang AB. So far none of the parties have confirmed the purchase, but according to The Wall Street Journal the deal is near.

Mojang and Minecraft
Mojang logoMojang AB is the company behind the independent game Minecraft, a survival sandbox game that has been sold in 50 million copies. But Minecraft is more than a game, and I think that is the reason for Microsoft's interest in Mojang.

Minecraft is used in schools, and in the Block by Block project Mojang has partnered with The United Nations Human Settlements Programme (UN-Habitat) to let people plan urban public spaces using Minecraft.

The owner of Mojang is a young Swede, Markus Alexej "Notch" Persson. When he founded his company in 2009 he gave it the name "gadget" – "mojäng" in Swedish. The Minecraft success has attracted interest from many important investors, but so far "Notch" has refused all outside investments. Now it sounds as if he has changed his mind.
Safari Park Photo

Third Nordic acquisition
If the Mojang deal is completed, it will be the third Microsoft acquisition of a Nordic company in a few years. Being a Swedish software developer, I cannot help but feeling proud of being part of the Nordic ingenuity. Even if Microsoft has shown no interest in a investment – yet!

Skype logoIn May 2011 Microsoft bought Skype, a company I still have strong feelings for as I worked there between 2005 and 2010. I was one of the first 100 people employed, and during my time as Product Manager for Skype Toolbars I experienced the immense growth of the company.

In April this year came the long awaited purchase of Nokia Devices and Services. The affair with Mojang is more of a surprise, and it will be interesting to see what it will lead to.

Peter Kalmstrom
CEO and Systems Designer Business Solutions