The blog of Wictor Wilén

The blog of Wictor Wilén - SharePoint Certified Architect, Certified Master and Most Valuable Professional

RSS RSS
  • Presenting at TechX Office 365 January 23-24 2014

    Tags: Conferences, Office 365

    imageThis year has barely started but the conference season is already running at full speed. The first conference for me of this year will be the TechX Office 365, here in Stockholm, Sweden.

    This is a conference organized by Microsoft with sole focus on Office 365. There will be national and international speakers of top class. I will do two presentations, one about Building Apps for SharePoint [Online] 2013 and one about Building Apps for Office  2013.

    The conference is held January 23rd to 24th at the Microsoft offices in Stockholm (Akalla). There are still a few seats left, so hurry over to get your ticket.

  • Summing up the year of 2013 and embracing 2014

    Tags: SharePoint, Azure, Personal, SharePoint 2013, Office 365

    Wow, 2013 was an interesting year and the time has come for my annual blog post to sum up the year that soon has passed us and looking a bit into the crystal ball for the next one. This is my seventh summary post and it is always fun to look back at what has happened during the last 12 months (2012, 2011, 2010, 2009, 2008, 2007 and 2006).

    For me the year has been really intensive on all levels; I don't think I´ve ever experienced such a huge demand for my professional services as of now, there is so much new stuff to learn and it´s harder and harder to keep up, I have a hard time resisting doing tons of community stuff and at the same time we had a huge construction work at our house, and of course having two soon-to-be teenager girls takes its toll!

    Writing

    The number of blog posts I create every year continues to decrease, but I do hope the quality improves and that you still get some decent value out of my posts. There are so many good bloggers out there and I don´t want to repeat what everyone else is writing about. There are a couple of posts that I´m quite proud of and here´s the list of the ones you have visited the most the last 12 months:

    There´s no coincidence that four of the top five posts written this year is about Office Web Apps Server 2013 (WAC) – it is my new favorite server product, and I think it is one of the core server products/services that will be a huge and integral part of the "One Microsoft" and its services.

    I also had the benefit of participating in a "real" writing project – as a co-author of "Inside Microsoft SharePoint 2013". This was my second book written together with some of the most famous SharePoint book authors. If you still haven´t ordered yourself a copy then you´re missing out on something!

    Speaking

    I´ve continued to do sessions at conference, perhaps not that many this year. I try to choose conferences that fits me, my family and clients and also I try to focus on creating good, new and interesting content. I´m not the kind of person that like to do the same content over and over again. I´m incredibly lucky being in this position and being able to travel and meet all the awesome people around the world. I know there are a couple of conferences that I would like to have presented at, but had to turn down due to other commitments…maybe next year. To read more about the presentations I´ve done over the last year and see the decks and some video recordings, check out my Presentations page.

    MVP

    I got re-awarded the MVP status once again, now my fourth time. It´s always really nice to be given this award.

    MCSM

    Talking about the Microsoft Certified Solutions Master, MCSM, could be a couple of posts on its own, but let´s try to crunch it down. Early January this year I attended the beta rotation of the brand new MCSM program for SharePoint. This program was totally redone to suit both on-premises SharePoint 2013 and Office 365/SharePoint Online (contrary to what some people think and say). There is/was no better training for SharePoint, in the cloud or not, than this program, and there will never be such a good program again! I was fortunate to pass both the written exam and the qualification lab "in-rotation" (that is no retakes or anything), being one of the first ones. Unfortunately the whole MCSM program was cancelled during this year. But once a Master always a Master. I´m really proud that I am one of the few who has passed MCM for SharePoint 2010, MCA for SharePoint 2010 and MCSM for SharePoint (2013) – a bit sad I didn´t get the chance to get the 2007 exam and get a full hand :-(

    SharePoint…

    Can´t write this post without a little section about SharePoint. What will happen to SharePoint, will it cease to exist? To some degree I do think so. But SharePoint as a product has played out its role in my opinion. SharePoint is just a piece in the puzzle of future collaboration software. Take a look at how Workflow has been moved out of SharePoint, how Office Web Apps is a separate product, how applications now are Apps outside SharePoint, how Enterprise Social now is a service (in Yammer). SharePoint will be there in the form of building sites and acting like a glue between all the other services. Will it be known as SharePoint? I don´t really know, but in a few years, I don´t think so. It sounds like judgment day for some, and it might be, unless you are prepared. I think this "brave new world" will for the ones who can accept the change be full of opportunities…and I´m looking forward to it! On the other hand the recent messages from Redmond that SharePoint on-premises ensures the current on-premises customers that SharePoint as a product will be here for another couple of years, which is good, it gives you good options to slowly move from a product to a service. But the innovation will be in the services, Office 365 and Azure, not in the products.

    Predictions

    Last year's predictions was not that off the chart. The Cloud message is ever increasing, and there´s no end to it. I also predicted a "collapse" of the SharePoint community, to some degree I think that has started to happen. The community is still thriving but there is not a single community as it used to be. There has been several new community sites and community conferences started this year. Not that it is a totally bad thing, but in my opinion it does not help the community moving forward. We´re also seeing many of the old community celebs and influencers moving away from SharePoint as a specialty and instead focusing on the new set of services.

    So what about 2014 – what do you think Wictor?

    SharePoint is dead, long live SharePoint. I wrote it above; SharePoint as a product is slowly going away, instead "SharePoint as a service" is where the focus should be. If anyone of you watched the PDC08 keynote, when Azure was announced – do you remember the slide where "SharePoint Services" was one of the listed services. I think this is where we´re going, six years later.

    Azure domination! The Azure team at Microsoft is really impressive right now, look at all the different services they announce and improve. Being a bit late to the game, but now being captain of the Cloud movement. If it was something I would bet my career on now, it would be Azure.

    Services, services, services! Everything will be services. Combine the things I said about SharePoint, with the things about Azure and add the recent announcements of the killed ForeFront products (and others). Microsoft is all in on the Devices and Services thing and you should be too. This changes the way we design, build and sell our professional services.

    The future does look a bit cloudy, doesn´t it.

    Happy New Year

    That was it! I do have a lot more to say, but you all should be on vacation right now stocking up on energy for 2014 so I keep it short. Next year will be an intensive year for me, I know it. I´m already excited about the new engagements I have planned for early 2014, about the SharePoint Conference in Las Vegas (last SP conference?) where I will be a presenter for the first time, and also the big change at Microsoft with a new CEO – how will that affect me!?

    So, to all of you I wish a Happy New Year and I´m looking forward to seeing a lot of you out there next year!

  • SharePoint 2013 Architecture Survey

    Tags: SharePoint 2013, Conferences, Surveys

    Happy Holidays everyone!

    At the upcoming SharePoint Conference, next year in Las Vegas, I will be presenting a session called Real World SharePoint 2013 Architecture decisions. The session will discuss and give examples of real world decisions and trade-offs you might be faced with as a SharePoint Architect. In order to make the session even more interesting I would like you all to help out with some statistics. Therefore have I created a small survey with a few questions. Filling it out should not take you more than an a few minutes, so there is no excuse not to do it.

    You can answer the questions either with data from your own companys standpoint, or if you are a consultant you are free to answer with your current project(s).

    The survey in it's full glory can be found here: http://askwictor.com/SPC14Survey

    Feel free to spread this link cross all your networks, the more data I have the more interesting it will be.

    The results will contribute to the SPC334 session and will shortly after that be presented here on this blog.

  • I will be speaking at SharePoint Conference 2014 in Las Vegas

    Tags: SharePoint 2013, Conferences

    SharePoint Conference 2014I’m really proud to announce that I will be speaking at the long anticipated SharePoint Conference 2014 in Las Vegas, March 3-6 2014. The SharePoint Conference hosted by Microsoft is returning to Las Vegas, but this time located at the Venetian, bigger and perhaps more interesting than in a long time. If you are in the SharePoint business as a developer, IT-Pro, architect, business analyst, power user or executive, then this is the conference where you would like to be next year.

    For the first time I will be speaking at this conference, which I’m really excited and a bit nervous about. I will present two sessions of which I’m really passionate about:

    SPC383: Mastering Office Web Apps 2013 deployment and operations

    Tuesday 4/3 9:00-10:15 @ Lido 3001-3103

    Microsoft Office Web Apps 2013 is a crucial part of any SharePoint, Exchange and Lync on-premises deployment. In this session we will dive into the details of planning, deploying and operating your Office Web Apps server farm. Through a great number of demos we will create a new farm from scratch, make it highly available and then connect it to SharePoint and Exchange. We will cover aspects such as scale considerations, patching with minimum downtime and security decisions you have to take as a Office Web Apps farm admin.

    SPC334: Real-world SharePoint architecture decisions

    Wednesday 5/3 13:45-15:00 @ Lido 3001-3103

    Being a SharePoint architect can be challenging - you need to deal with everything from hardware, resources, requirements, business continuity management, a budget and of course customers. You, the architect, have to manage all this and in the end deliver a good architecture that satisfies all the needs of your customer. Along the line you have to make decisions based on experience, facts and sometimes the gut feeling. In this session we will cover some of the architectural changes in the SharePoint 2013 architecture, some of the new guidance from Microsoft and provide insight into a number of successful real-world scenarios. You will see what decisions were made while designing and implementing these projects with emphasis on why they were made.

    SPC356: Designing, deploying, and managing Workflow Manager farms

    Wednesday 5/3 10:45-12:00 @ Lido 3001-3103

    Workflow Manager is a new product that provides support for SharePoint 2013 workflows. This session will look at the architecture and design considerations that are required for deploying a Workflow Manager farm. We will also examine the business continuity management options to provide high availability and disaster recovery scenarios. If you want a deep dive on how Workflow Manager works, then this is the session for you.

    I very glad to be doing this Workflow session since it will be co-presented with my buddy, the almighty MCA/MCM/MCSM/MCx Spencer Harbar!

    I’m really looking forward to seeing you there, in my sessions, in the other interesting sessions, in the casinos and … I’ll better stop there – what happens in Vegas stays in Vegas…

    [Updated 2014-02-19] Added rooms and time slots as well as the SPC356 session.

  • Inside Microsoft SharePoint 2013 is here, just in time for the holidays…

    Tags: SharePoint 2013, Books

    Inside Microsoft SharePoint 2013I remember a person who clearly stated “I will never ever write a book again”. Yup, twas me. I managed to hold that promise for a year and a half. But when an interesting opportunity appears, I’m usually all-in again. And so it was.

    Early this year I got the request from some dear friends to help with writing another book, fortunately this time not as the single responsible author but instead together with a really experienced bunch of SharePoint people, whose knowledge and resume are really impressive. I was asked to participate to write two chapters in the Inside Microsoft SharePoint 2013 book, published by Microsoft Press.

    This is a book for every single developer out there, newbie, apprentice or master candidate (oh, there is no such thing anymore…), that has interest of SharePoint 2013 – yes, that is most likely you. This is the book that you should have in your toolset. It is packed with everything from the basics up to the more advanced scenarios, covering all the different workloads of SharePoint 2013.

    If you take a look at the authors of this book you know it’s a keeper: Scott Hillier, Mirjam van Olst, Ted Pattison, Andrew Connell, Kyle Davis and little ol’ me.

    If you order it now you will have it by Christmas!

    Oh, and today you get %50 discount on the book here!

  • SharePoint 2013: Fix to the “Could not find Stored Procedure Search_GetRepositoryTimePerCrawl” error

    Tags: SharePoint 2013

    Introduction

    In this post I will show you how to fix the “Could not find Stored Procedure ‘Search_GetRepositoryTimePerCrawl’” exception in SharePoint 2013. This is an exception that you can get when looking at crawl log details for a Search Service Application. The error might go unnoticed since it will not affect indexing or querying.

    Could not find stored procedure Search_GetRepositoryTimerPerCrawl

    Symptoms

    In SharePoint 2013 when you are trying to inspect crawl logs and statistics for indexing and querying you might see exceptions that say “Could not find stored procedure ‘Search_????’”. You will also see critical errors in the ULS Trace Logs like this:

    SharePoint Foundation Database 880i High     System.Data.SqlClient.SqlException (0x80131904): 
    Could not find stored procedure 'Search_GetRepositoryTimePerCrawl'.
    SharePoint Foundation Database 5586 Critical Unknown SQL Exception 2812 occurred. 
    Additional error information from SQL Server is included below.  
    Could not find stored procedure 'Search_GetRepositoryTimePerCrawl'.
    

    Note that the name of the Stored Procedure may vary.

    The Trace Logs reveals that there are missing stored procedures in the Usage Database and by cranking up SQL Server Management Studio it clearly shows that there are no stored procedures with those names. You will only see one stored procedure (or sometimes none) with the Search_ prefix.

    Missing sprocs

    Even though these Stored Procedures are missing the Search Service Application continues to crawl and index and querying works as normal.

    Cause and Resolution

    There might be several causes for this error. One reason could be that the Usage Database has been recreated (for instance to increase the max total bytes in the partitions). When the Usage Database is created it will only contain the default set of stored procedures, it is not aware of any Service Application or custom Usage Providers.

    In this case the Search Service Application Usage Provider has not created the necessary Stored Procedures in the database. This is done by a timer job called “Search Health Monitoring – Trace Events”. Once this timer job has executed successfully the required stored procedures should be created. Normally this timer job is executed every minute, so seeing this error should be very infrequent. But just as any timer job an admin can change the schedule or even disable it – and then when the Usage Database is re-created this error will occur.

    Sprocs is back!

    Summary

    You’ve just seen the cause and fix for the missing stored procedures when looking at crawl and query logs and statistics in SharePoint 2013. The error messages might be frightening but the fix is quick and easy. Just as anything in SharePoint once you understand the moving bits and pieces.

  • SharePoint Saturday - In Stockholm for the first time

    Tags: SharePoint, Conferences

    imageFinally we’re getting SharePoint Saturday to Stockholm! Next year in January, or to be more precise the 25th of January 2014, the global SharePoint Saturday event will come to central Stockholm and World Trade Center.

    What is a SharePoint Saturday?

    SharePoint Saturdays are a free events that happens in cities around the world, unfortunately most of them are on the other side of the pond. But once in a while we see these great events pop up in Europe. It’s free in that meaning that it is organized by volunteers, the speakers do it because they have nothing better to do on Saturdays and there is no entrance fee and if you’re lucky you can get some swag as well! But, the events are sponsored, but just to get a good venue and of course the accompanying SharePint after a full day of sessions.

    SharePoint Saturday Stockholm

    As I said, now for the first time we will have our first SharePoint Saturday here in Stockholm. The event is organized by my colleague Hannah Swain, Mattias Einig and fellow MCM Erwin van Hunen – a great bunch of committed people They are currently setting up the speakers, agenda, venue and all of gazillion things that needs to be done. The event will be held at World Trade Center, which is right in the middle of Stockholm and as close as you can get to all the communications.

    You can be a speaker!

    One of the key things, and what I really like with these events, is that everyone can and should apply for a speaker slot. It’s a great opportunity to practice your speaking skills, learn more about how it is to contribute to the community, get your name out there and perhaps boost your ego a bit. I know that there are lots of people, including shy Swedes, that can, will and should be on our very first SharePoint Saturday as a speaker. Don’t just sit there – go and submit your sessions proposals right away!

    I’m really looking forward to meet all of you there!

  • The correct way to execute JavaScript functions in SharePoint 2013 MDS enabled sites

    Tags: SharePoint 2013, MDS

    Introduction

    JavaScript is the future of SharePoint development (and please don’t quote me on that :-). JavaScript is everywhere in SharePoint 2013 and upcoming incarnations, and you will see a couple of posts on this topic from me in the future. The JavaScript language is easy (well, sort of), but the many different implementations and API’s built using JavaScript might cause confusion. One of the things in SharePoint 2013 that makes JavaScript development quite problematic is the Minimal Download Strategy (MDS) in SharePoint 2013. In this post I will show you what to think of when building JavaScript features on top of SharePoint and make them aware of MDS and make them work with MDS.

    Minimal Download Strategy

    Almost a year and a half ago I wrote the Introduction to the Minimal Download Strategy (MDS) post, which since then surprisingly been one of the most visited ones on this little site! I won’t recap everything in that post, but basically MDS is a framework that allows SharePoint 2013 to download and render pages more efficient by focusing on only those parts of the page that actually needs an update. For instance, when navigating between folders in a document library, we do not need to re-render the top bar or footer etc. All this to make the perceived performance better and to reduce bandwidth.

    The Problem

    The big problem with MDS is that it only works well with the out-of-the-box stuff on a Team Site, or similar templates. As soon as you start to drop your own Web Parts, custom scripts or customizations that has not been adapted for the Minimal Download Strategy you will not see any performance benefits, au contrary you will see a performance degradation in many cases – so you turn the MDS feature off.

    One of the biggest problems is that the more and more customizations in SharePoint involves JavaScript and so far I have not seen a single non-SharePoint native script that can handle MDS that well, and I’ve been bashing my head against the wall for some time to get it to work properly. Many, if not most, JavaScripts want to execute a function when the page loads either to initialize something or to change something (haven’t we all seen all those dreaded jQuery UI customizations that could have been done with a simple CSS fix!). Common approaches to this is to use the SharePoint _spBodyOnLoadFunctionNames.push() or the jQuery $(document).ready() {} method. These methods rely on the DOM events when the page loads, so it might work perfectly fine on your first page load when MDS is enabled, since we need to fetch the full page, but on subsequent page transitions the JavaScript will not fire. An MDS page transition does not fire any DOM document load events since it asynchronously partially updates the page.

    A non MDS compatible custom field using JSLink

    List with custom JSLink columnLet’s take a look at an example using a simple Field using Client Side Rendering (or JSLink) that just makes negative numbers red and positive numbers black.

    This is how my field is defined using CAML. In this sample I create everything as a Sandboxed, purely declarative solution, but it’s easy to create the exact same solution using a SPApp or a Full Trust Code solution.

    <Field
          ID="{ce3d02df-d05f-4476-b457-6b28f1531f7c}"
          Name="WictorNumber"
          DisplayName="Number with color"
          Type="Number"
          Required="FALSE"
          JSLink="~sitecollection/Wictor/NumberWithColor.js"
          Group="Wictor">
    </Field>

    As you can see it is a standard Number field with a JSLink attribute. Next I deploy the JavaScript file, using a Module element, that looks like this:

    var Wictor = window.Wictor || {}
    Wictor.Demos = Wictor.Demos || {};
    Wictor.Demos.Templates = Wictor.Demos.Templates || {}
    Wictor.Demos.Functions = Wictor.Demos.Functions || {}
    
    Wictor.Demos.Functions.Display = function (context) {
    	var currentValue = context.CurrentItem.WictorNumber
    	if (currentValue > 0) {
    		return currentValue;
    	}
    	else {
    		return '<span style="color:red">' + currentValue + '</span>'
    	}
    }
    
    Wictor.Demos.Templates.Fields = {
    	'WictorNumber': {
    		'DisplayForm': Wictor.Demos.Functions.Display,
    		'View': Wictor.Demos.Functions.Display,
    		'NewForm': null,
    		'EditForm':  null
    	}
    }
    
    SPClientTemplates.TemplateManager.RegisterTemplateOverrides(Wictor.Demos)

    Everything is pretty straight forward. I define a couple of namespaces (which imo is a good coding practice), create a display function for my custom field, create the JSLink templates and finally registers the templates with the TemplateManager. I will not dive deep into the JSLink stuff, but if you need a really good guide I urge you to read Martin Hatch’s JSLink series.

    Once this little solution is deployed and the features activated we can add the field to a list and it should work pretty fine, unless we have MDS enabled on our site and start navigating back and forth between pages within the site. Once you navigate away from the list, containing this custom field, and navigate back using MDS page transitions it will stop using our custom template. Not funny..

    The Solution to these problems

    Fortunately there is a solution to this problem and there are two things that are really important.

    The RegisterModuleInit method

    The first reason that our field does not use the template that we defined in JavaScript is due to the fact that we register the templates with the field only when the JavaScript is loaded and executed. When navigating, using MDS, to another page this registration is reset and the JavaScript file is not evaluated again. So we need to find a way to register the module each and every time that page is used. Traditional web browsing, with full page reloads, allows us to use jQuery $(document).ready or the SharePoint function _spBodyOnLoadFunctionNames.push() to do these kind of things. But, they only do stuff when the page load event is fired – and an MDS page transition does not trigger that event.

    The SharePoint team has of course not forgotten about this scenario and has given us a JavaScript function called RegisterModuleInit(). This method is specifically designed for these kind of scenarios, we can use it to add methods that are to be executed whenever a page transition in MDS is done. The RegisterModuleInit() function takes two parameters; the first one is the path the the JavaScript file that is associated with the function to execute and the second parameter is the function to execute. One really important thing is to note that the the path to the JavaScript file must be exactly the same as used when registering it, so depending on if it’s loaded from the Layouts folder, a folder within the site etc you have to make sure to use the exact same path in the RegisterModuleInit().

    Let’s rewrite the last part of our JavaScript file and replace the line that registers the templates with these lines:

    Wictor.Demos.Functions.RegisterField = function () {
        SPClientTemplates.TemplateManager.RegisterTemplateOverrides(Wictor.Demos)
    }
    
    RegisterModuleInit(
      _spPageContextInfo.siteServerRelativeUrl + 'Wictor/NumberWithColor.js', 
      Wictor.Demos.Functions.RegisterField)
    
    Wictor.Demos.Functions.RegisterField()

    I’ve encapsulated the template registration into a new function, called RegisterField(). We then use the RegisterModuleInit() function to register this function to be executed whenever our JavaScript file is used on the page. The _spPageContextInfo object is used to get the site relative URL to which we append the relative path to where the JavaScript file is deployed. Finally we execute the RegisterField() function directly, since the RegisterModuleInit() only handles upcoming page transitions.

    If we now try this on an MDS enabled site you will quickly notice that you get JavaScript errors the second time we visit the list with this custom field, it should say something like below if you have a debugger attached or configured. In worst case MDS will notice that there is a JavaScript error and silently reload the page causing a second page load and reducing performance (you will then likely also see another JavaScript error, that we’ll talk about in a bit).

    Error: Unable to get property 'Demos' of undefined or null reference

    Looks like there’s something wrong with our namespaces!

    The Garbage Collecting issue

    The second issue requires some understanding of the Minimal Download Strategy and knowing that MDS actually has a built-in garbage collector (you didn’t see that coming right!). MDS will when doing a page transition clear up window scoped variables and delete them. This is a good thing, just imagine the number of potential JavaScript objects and structures that might have been created and stored in memory if you’re working within a site and jumping back and forth between pages. The good thing is that it will not delete objects that are properly registered as namespaces, and with that I mean Microsoft Ajax namespaces. Let’s go back to our very first sample, the one with a JSLink field. Remember I created a number of namespaces in the JavaScript file to hold my templates and functions. If I change the very first namespace definition in that file from:

    var Wictor = window.Wictor || {}

    To instead utilize the Microsoft Ajax Type.registerNamespace() function like this we will be golden:

    Type.registerNamespace('Wictor')

    Try that, redeploy your JavaScript with both the RegisterModuleInit() function and the Type.registerNamespace() declaration and you will see that (almost) everything executes just as expected. The field will render just as we want even though we navigate back and forth from the list containing the custom field.

    Getting it to work without MDS as well

    When disabling MDS on the site, or when using the “normal” URL to the list with the custom field, when a JavaScript occurs like above and on some other occasions your page will do a full page load, that is not an MDS page transition, you will get a JavaScript error that states:

    Error: '_spPageContextInfo' is undefined

    In this case the JavaScript object that we use to get the site relative URL is not created and does not exist. You will not get this error while doing MDS page transitions, since that object is created on the first page load. So how do we handle this situation?

    Since we don’t have the _spPageContextInfo object on the page, then we cannot do the RegisterModuleInit() move. But on the other hand if we get into this situation, we’re not in “MDS mode” and does not need it…clever huh! Also note, that we can get around this error by not using a site relative path and deploying stuff into the Layouts folder – but try to do that in the cloud. Let’s rewrite the last part again:

    Wictor.Demos.Functions.RegisterField = function () {
        SPClientTemplates.TemplateManager.RegisterTemplateOverrides(Wictor.Demos)
    }
    
    Wictor.Demos.Functions.MdsRegisterField = function () {
        var thisUrl = _spPageContextInfo.siteServerRelativeUrl
    		+ "Wictor/NumberWithColor.js";
        Wictor.Demos.Functions.RegisterField();
        RegisterModuleInit(thisUrl, Wictor.Demos.Functions.RegisterField)
    }
    
    if (typeof _spPageContextInfo != "undefined" && _spPageContextInfo != null) {
        Wictor.Demos.Functions.MdsRegisterField()
    } else {
        Wictor.Demos.Functions.RegisterField()
    }

    We still have a function for registering the field with the template manager, exactly the same as previously, then we introduce another method that is only used when MDS is enabled and we’re in MDS mode, that method uses the _spPageContextInfo to register the script to run for each MDS page transition. Finally we do a check in our JavaScript that if the _spPageContextInfo exists, then use our MdsRegisterField method otherwise just call the function that registers the template.

    Our full JavaScript should now look something like this:

    Type.registerNamespace('Wictor')
    Wictor.Demos = Wictor.Demos || {};
    Wictor.Demos.Templates = Wictor.Demos.Templates || {}
    Wictor.Demos.Functions = Wictor.Demos.Functions || {}
    
    Wictor.Demos.Functions.Display = function (context) {
    	var currentValue = context.CurrentItem.WictorNumber
    	if (currentValue > 0) {
    		return currentValue;
    	}
    	else {
    		return '<span style="color:red">' + currentValue + '</span>'
    	}
    }
    
    Wictor.Demos.Templates.Fields = {
    	'WictorNumber': {
    		'DisplayForm': Wictor.Demos.Functions.Display,
    		'View': Wictor.Demos.Functions.Display,
    		'NewForm': null,
    		'EditForm':  null
    	}
    }
    
    Wictor.Demos.Functions.RegisterField = function () {
        SPClientTemplates.TemplateManager.RegisterTemplateOverrides(Wictor.Demos)
    }
    
    Wictor.Demos.Functions.MdsRegisterField = function () {
        var thisUrl = _spPageContextInfo.siteServerRelativeUrl
    		+ "Wictor/NumberWithColor.js";
        Wictor.Demos.Functions.RegisterField();
        RegisterModuleInit(thisUrl, Wictor.Demos.Functions.RegisterField)
    }
    
    if (typeof _spPageContextInfo != "undefined" && _spPageContextInfo != null) {
        Wictor.Demos.Functions.MdsRegisterField()
    } else {
        Wictor.Demos.Functions.RegisterField()
    }
    

    Now, when we test this solution it should work with and without MDS enabled on the site, on all MDS Page transitions back and forth and we spare at least a handful of kittens using this code.

    Summary

    I’ve just shown you how you create a custom field rendering using JSLink that works with and without MDS. It requires you to pop in a set of additional JavaScript lines into each JavaScript file, but it is basically exactly the same JavaScript snippet each and every time. This solution does not only work for JSLink fields, it is valuable for delegate controls, web parts, ribbon customizations etc. How my life had been easier if this had been documented on MSDN twelve months ago…

    PS: If you find any situation where this does not work, please contact me and I’ll try to extend the scenario to cover that as well.

  • Clearing up the confusion with Host Named site collections and Path Based site collections

    Tags: SharePoint 2013

    Introduction

    I’ve been reading and seeing a lot of blog posts, articles, videos etc over the last few months discussion Host Named site collections vs Path Based site collections in SharePoint 2013, and 2010 for that matter. What I find interesting is that a lot of those articles are either misinterpreting the official guidance and documentation on TechNet or are just plain wrong. In this post I will try to clear up some of the confusion, and hopefully I’m not that wrong in this post. And yes, I can agree that Microsoft could have been more clear on this topic, but what’s there is actually pretty decent.

    What are Path Based site collections?

    Let’s start with Path Based site collections (PBSC) which has been the traditional method of creating and locating site collections. It’s based on the fact that you have a Web Application (IIS Web Site) in SharePoint listening to a specific host header, (1) in the picture below. Then each site collection is located relative to this host header. A site collection can only exist under (wildcard) or in (explicit) a managed path, (2) in the picture below. The URL to the site collection is the combination of the protocol, host header, the managed path and the name of the site collection. In order to have different host names, multiple Web Applications must be created, as in the example below where the Personal Sites are located on a different host name. When using Path Based site collections you configure the managed paths on a web application level,

    Path Based site collections

    The illustration above shows us how we need two Web Applications to host two different host names; one for intranet.contoso.com and one for my.contoso.com, and that we use different managed paths in the two different Web Applications.

    Path Based site collections has been the de facto, and also recommended approach, and therefore it’s the most well-known method. All configuration can be done using SharePoint Central Administration and most admins are familiar with managing Path Based site collections.

    What are Host Named site collections?

    Now, let’s take a look at Host Named site collections (HNSC). Host Named site collections have now been the “recommended” approach, very much to the fact that SharePoint Online/Office 365 uses it and it is now the most tested (by Microsoft) method. Note that this alone does not validate that HNSC should be the default method for all new deployments.

    The largest difference compared to Path Based site collections is that all site collections now have its own URL and that the web application should not listen to a host header (3), but all incoming requriest. Even though the site collections themselves have their own URL, site collections can only be created under/in a managed path. The managed paths used by HNSC are not the managed paths configured at the web application but instead they are configured on the Farm level (4).

    Host Named site collections

    One of the “myths” around Host Named Site Collections is that you cannot use managed paths, which is completely wrong. As you can see by the illustration this web application uses multiple host names and multiple farm level managed paths. You can see that we have intranet.contoso.com and my.contoso.com in the same web application. We could also add new site collections for search.contoso.com or teams.contoso.com, just as long as the DNS (and certificate) is configured correctly for the IIS.

    One of the caveats with HNSC is that you cannot configure anything of this using Central Administration. You need to use PowerShell to create the web application, managed paths and each and every site collection.

    Note: also note that the web application above have a root site collection without a site template. This is currently a support requirement. For instance see this support article KB2590564.

    Do I need to choose one of HNSC or PBSC methods?

    This is one of the largest misconceptions in this discussion. No, you do not have to choose either HNSC or PBSC. As usual with SharePoint – it depends! It depends on your requirements. For instance if you want process isolation of site collections, then you can use HNSC for the most of your site collections and then use PBSC for those who need to be in separate application pools – all you need to do is configure your DNS and the correct host headers on your PBSC. Requirements of alternate access mappings might also be a reason to think of PBSC.

    So, which method should I use then?

    My recommendation is that you always start your design with Host Named site collections. It gives you way more flexibility in the way you give host names to your site collections. You will also reduce the memory footprint of SharePoint on the web servers. Of course as always if you get bad code in your SharePoint farm which takes the application pool down – all of your sites will go down. Depending on your scalability requirements you might need to evaluate the needs of HNS and/or PBSC.

    The TechNet article referenced below contains even more details on some subtle and significant differences between HNSC and PBSC – make sure to read and understand those before starting your design. Well, you can always export and import site collections between the two methods if you need to change the structure at a later stage – but the end users will most likely not be fond of that.

    References

    Here are some important and authorative articles and posts on the topic that you should read:

    Kirk Evans, Microsoft: What Every SharePoint Admin Needs to Know About Host Named Site Collections

    TechNet: Host-named site collection architecture and deployment (SharePoint 2013)

    Summary

    I hope that this post cleared up the confusion between Host Named site collections and Path Based site collections. Which method to choose is always up to you and your requirements. I did not go into all the nitty gritty configuration details in this post, and leave that for now or to the TechNet article...

  • Office Web Apps Server: Which version is installed?

    Tags: Office Web Apps, WAC Server

    If you have been working with SharePoint you should know by now how to get the build version of an installation using PowerShell. Knowing the version of the installation is crucial for troubleshooting and knowing what features or limitations the current installation has, given the new release cadence. If you don’t know how to do it then Bing for it and then return here. But how do you do the same for Office Web Apps Server 2013?

    Retrieve the version number of an Office Web Apps Server installation

    Knowing the current version for Office Web Apps Server 2013 (WAC) is also important to know. Just as with SharePoint new features and bugs can and will be introduced over time and you need to know the version to be able to correctly get support and to patch it. Unfortunately there is not such an easy approach as with SharePoint – we cannot use the WAC cmdlets to get the current build version.

    Instead we can rely on another PowerShell method – Invoke-WebRequest. Hmm, that has nothing to do with WAC you might be thinking, which is true. But Office Web Apps returns the current version as an HTTP Header – the X-OfficeVersion header.

    In order to do use this cmdlet and to invoke an HTTP request we also need to send an anonymous request, to avoid 401’s. For this we can use one of the anonymous end-points that Office Web Apps Server exposes, for instance the end-point for the broadcast ping, like this:

    (Invoke-WebRequest https://wac.contoso.com/m/met/participant.svc/
    jsonAnonymous/BroadcastPing).Headers["X-OfficeVersion"] 

    As you can see we request the endpoint, and retrieve the specific version header from the response. This will return the current build version of your WAC farm, for instance “15.0.4535.1000” which is the August 2013 hotfix for WAC.

    Known version numbers

    I have collected the known version numbers of Office Web Apps Server 2013 on this page http://www.wictorwilen.se/WACVersions. I will try to continuously update it as the WAC server retrieves new patches and upgrades. As a bonus I also added version numbers for the version that SkyDrive currently uses (interesting!).

AWS Tracker

About Wictor...

Wictor Wilén is a Director and SharePoint Architect working at Connecta AB. Wictor has achieved the Microsoft Certified Architect (MCA) - SharePoint 2010, Microsoft Certified Solutions Master (MCSM) - SharePoint  and Microsoft Certified Master (MCM) - SharePoint 2010 certifications. He has also been awarded Microsoft Most Valuable Professional (MVP) for four consecutive years.

And a word from our sponsors...

SharePoint 2010 Web Parts in Action