Nick Hadlee's Blog on SharePoint and Other Occasional Rants…

Intergen Blog: SharePoint 2013 Search
October 2, 2012, 8:33 pm
Filed under: 2013, Intergen, Search, SharePoint

I wrote a post over at the Intergen blog on SharePoint 2013 Search:

Search is an area of SharePoint that has been greatly improved with the forthcoming SharePoint 2013 release from Microsoft. The changes range from a new richer user interface through to a completely revamped back-end architecture…

Read more from this post at the Intergen Blog and while your at it have a look at the rest of our SharePoint 2013 series.

My Tech Ed NZ Session: What’s New in SharePoint 2013 Search?
September 15, 2012, 5:01 pm
Filed under: 2013, Search, SharePoint, Tech Ed | Tags: ,

I was luckily enough to attend and present at Tech Ed New Zealand again this year. My session was OSP206: What’s New in SharePoint 2013 Search?

It was a 200-250 level session to look at the changes from a few different perspectives:

  • The new UI
  • The new architecture
  • Administration changes
  • Developer changes
  • A demonstration of customising search results using Display Templates and Query Rules

I had a lot of fun attending and speaking at Tech Ed and really can’t wait for SharePoint 2013 to be released! Until then here are the slides from the session.

PowerShell and SharePoint Scripts from Tech.Ed NZ and Code Camp 2011
August 31, 2011, 9:59 pm
Filed under: 2010, Administration, PowerShell, Presentations

I recently did a PowerShell and SharePoint session at Tech Ed NZ 2011 and then again during Code Camp in the following weekend. The focus was on using PowerShell to create and configure a SharePoint portal and as promised here is a list of the scripts I used during my demo.  These scripts and a couple other useful files are in my SkyDrive so you can go and grab them individually. The whole lot is in the same place as a zip too.

This is the order that I showed and used them (or intended to):

  1. Add a managed account
  2. Add and configure a web application
  3. Add the managed metadata service application (Didn’t run this one just showed it)
  4. Adding site collections
  5. Configuring and adding content databases
  6. Backup and restore the farm, a service application and/or a web application (Didn’t run this one just showed it)
  7. Backup and restore a site collection
  8. Start a search crawl
  9. Add some sub sites
  10. Change the site collection properties to point to a search center
  11. Change the site properties to use alternate CSS and a site logo
  12. Adding users to the sites and adding a second site collection administrator
  13. Walkthrough of the web hierarchy (webs, lists, list templates, content types, fields)
  14. Basic deploy of solutions (WSP’s)
  15. A better way to deploy solutions
  16. Turning on the developer dashboard
  17. Checking the ULS

Note: These scripts were kept pretty simple to make them easy to read and describe during the demo. I’d strongly recommend you add a bit of error checking, maybe a few if/check statements etc before just running them willy nilly. Also some things were commented out during the sessions – uncomment them at your leisure.

Code Camp Slide Deck

The Code Camp slide deck is more or less the same as the Tech.Ed one.

No Search Results for Contextual Scopes
July 24, 2011, 12:22 pm
Filed under: 2010, Search, Troubleshooting

Contextual scopes are a really useful way of performing searches that are restricted to a specific site or list. The “This Site: [Site Name]”, “This List: [List Name]” are the dead giveaways for a contextual scope (I even think you can get a folder context too “This Folder” but it alludes me most of the time).  What’s better is contextual scopes are auto-magically created and managed by SharePoint for you so you should pretty much just use them in my opinion.

You may come across a problem where SharePoint search works fine except for your contextual scopes. Your global search scopes all return results but for some strange reason the contextual scopes are empty…

I came across this problem a couple of times recently and the fix is really pretty simple – check your alternate access mapping (AAM) settings and make sure the host header that is specified in your default zone is the same url you have used in your search content source. Normally SharePoint kindly creates the entry in the content source whenever you create a web application but if you have changed around any AAM settings and these two things don’t match then your contextual results will be empty. Case Closed!

Making Features that Deploy Content Types Compatible with the Content Type Hub
January 8, 2011, 10:55 am
Filed under: 2010, Content Types, Development, Tips & Tricks

* Update 15 May 2010 – this isn’t a problem! After some feedback from Chak’s and some retesting I’m happy to say that CAML features and the content type publishing hub work together fine. I can’t reproduce the problem and neither can Paul so I’m going to park this as a SharePoint X-File. I’d recommend you don’t use the method below unless you have a good reason to mix OM/CAML features in your deployment.

Paul Grimley wrote a post a while ago which highlighted a problem * with the content type publishing capability of SharePoint 2010. The particular problem highlighted by Paul’s post is the inability for content types to be published by the content type hub if they have been deployed by declarative CAML in a feature…seriously!

So we have two components of SharePoint 2010 – feature based content types and the content type hub – which are incompatible with each other. In my opinion there are lots of reasons you may want to deploy content types via features including:

  • Portability – deploying artefacts such as content types between environments such as DEVELOPMENT, UAT and PRODUCTION is much easier when they are wrapped up in a feature
  • Visual Studio 2010 support – you can leverage the content type SPI’s (SharePoint Project Item) for creating content types in your solution which provides a nice interface for selecting its parent etc etc
  • Readability – CAML based features are (sort of) human readable which sometimes makes it a lot easier to determine what is happening within the feature by reading the XML than the source code
  • Best Practice – haven’t we been told time and time again that it’s a best practice to deploy customisations to SharePoint via features and solutions?

So there are lots of reasons why we want to use features but we also want to use the content type hub, what are our options? After a bit of trial and error I came up with the following pattern that seems to work well albeit with a few limitations.

The Workaround

The API for 2010 provides a new constructor for the SPContentType class that lets us create a content type via the object model with a specified ID. This is a important change from the 2007 API which will be the basis of the workaround:

  • Create a base content type using the Object Model:
 string baseContentTypeId = "0x010100ee23a9df11631348b5a5ac7fdfd66b49";
SPContentTypeId contentTypeId = new SPContentTypeId(baseContentTypeId); SPContentType baseContentType = null;
baseContentType = contentTypes[contentTypeId];

if (baseContentType == null) {
	baseContentType = new SPContentType(contentTypeId, contentTypes, "Base Content Type Publishing");
  • Any content types that should be publishable via the content type hub must be a descendant of this base content type (either a child, grand child etc)
<!-- Parent ContentType: Base Content Type Publishing (0x010100EE23A9DF11631348B5A5AC7FDFD66B49) -->
<contenttype id="0x010100EE23A9DF11631348B5A5AC7FDFD66B4900e54d81511bac4ad0837dd2ca3fb228e7" version="0" inherits="TRUE" description="A feature based Content Type that is publishable via the Content Type Hub" group="Custom Content Types" name="Base Document Content Type" />

My preference is to create the base content type via a ‘pre-requisite’ feature and then create a separate feature with the CAML based content types which will be dependent on this base content type feature. So far I’ve tested this ‘pattern’ with the following results:

  • These CAML based content types are disconnected from the features XML upon creation. This means any updates to the feature will not affect the content types. Updates to the published content types can be made by forcefully deactivating/reactivating the features but this is a risky operation as you might not know what has happened to the content types once they have been published.
  • If the attribute Overwrite=”TRUE” is included in either the content type or a field used by the content type the content type it won’t be published. It doesnt matter if the content type is a descendant of your base (publishable) content type or not it will never be published if you use the overwrite attribute.
  • These content types can be updated via the feature upgrade framework.

Unfortunately there are more than just a few things in SharePoint that you expect to work a certain way, or just work, that don’t. I love the platform but occasionally these “it almost works” moments can be pretty frustrating! If you have any feedback on this workaround I’d be keen to hear from you.

The First SharePoint Saturday New Zealand
December 19, 2010, 3:13 pm
Filed under: Development, jQuery, SharePoint, SharePoint Saturday, WCF

The first SharePoint Saturday was held in New Zealand on Saturday the 11th of December. I may be a little biased but I think the event was a real success with at least 80-100 people, close to 20 sessions and 17 speakers. A big thanks to all our sponsors, the speakers and also the other organisers. These events are a lot of work to put on so it wouldn’t have been possible without all of these people!

Any of the session slides that have been made available by the speakers are up on the site and we will continue to try and get the rest. Look forward to seeing everyone at next years event…

My session was in the developer stream and built a SharePoint 2010 Alerting solution to show how 1) to build a custom WCF web service that returns JSON, 2) how SP.UI JavaScript namespace is used to interact with the status bar, notifications and modal dialogues and 3) how to call web services from jQuery. The session slides are provide below for anyone that wants them:

An Alternative Method for Using Custom Master Pages with Search in SharePoint 2010
November 6, 2010, 3:41 pm
Filed under: 2010, Cutomisation, Development, Search

Search is a fundamental component of any SharePoint solution and 2010 has some subtle differences and great improvements over its 2007 predecessor:

  1. One improvement are refiners, a new part of the search user interface (formerly known as facets), which allow you refine the search results based on metadata and even better they are extensible
  2. One important difference between 2007 and 2010 is the use of a specific master page in the Search Centres – the minimal.master master page

I’m not a big fan of minimal.master used within the Enterprise Search Centre so that’s the focus of the rest of this post. I’ll propose a way to deliver a fix which basically boils down to not using the minimal.master.

So what’s the problem with minimal.master? Minimal.master is a cut down master page that is new to SharePoint 2010 and used by both Enterprise Search and Office Web Apps. As the Search master page it lacks a few key components available in the other SharePoint 2010 master pages. One fundamental component that is missing in minimal.master are navigation controls.

Minimal.master navigation

The minimal.master lacks most of the usual navigation controls you expect and need.

v4.master navigation

V4.master has the standard top navigation and the new 2010 breadcrumb (hidden inside the folder “up” icon)

Missing the main navigation leaves an Enterprise Search Centre completely isolated from the rest of your SharePoint solution. This is a big limitation – is there are any situation where you shouldn’t be able to get from your search results back to the main and/or other sites?

So why don’t we just change the search master page to one of those other fully featured ones like V4.master? Yeah that was my first idea too. And look what we get…

v4.master applied to search

An Enterprise Search Centre with v4.master applied “floats” the search controls into the breadcrumb navigation.

That wasn’t the result I was expecting and I guess it wasn’t the result most people were expecting if they tried this? This is not a bug but one of those “by design” problems. What you’re seeing is the way the four page layouts of Enterprise Search have been implemented to work specifically with the placeholders in the minimal.master master page. Personally I think this was a poor implementation decision because it uses some of the core placeholders completely differently than the other OOTB SharePoint master pages. Compare V4.master and minimal.master:

Place Holder Use in Minimal.master for search Use in V4.master for…most other things
TitleInBreadCrumb Search controls Breadcrumb navigation controls
SPNavigation Empty in the master page. The search page layouts add page editing controls and the ribbon instead. Page editing controls and the ribbon

The Current Approaches to using a Custom Master Page with Search

We have two options if we want to get rid of the minimal.master from search and put back some of the things we have lost:

  1. Create a custom search master page that is compatible with the search page layouts; or
  2. Modify the search page layouts to make them compatible with an existing custom master page

If you want to do the first option and create a custom master page for search then Randy Drisgill has a really useful and detailed post on how to convert a V4.master (normal) master page to work with the Search Centre.

The second alternative solution is to modify the page layouts to work with your existing custom master page. I first came across the idea via Chris O’Connor and prefer this approach. It’s biggest benefit is you only have to develop/test/maintain one master page which can be used on all your SharePoint sites including the search site!

Unfortunately there is at least one negative side effect to modifying the search page layouts – it makes them unghosted (customized). Unghosted files are generally frowned upon in SharePointland so this approach won’t always suit everyone’s environment/requirements. The biggest problem, and a very valid reason to dislike unghosted files, is once they are customized a copy lives in the content database that is disconnected from the original file system version. This means:

  • These page layouts will not be updated by any changes to the file system versions such as solution (wsp) upgrades and service packs
  • There is a performance penalty (I don’t know how much?) because of the extra database hit required to retrieve the page layout from the content database

Fix Option 2. Explained

There are a few changes that have to be made to all of the search page layouts and your custom master page to implement fix option number 2. To make this as clean as possible I have packaged the changes into a sandbox solution and use a site collection feature (feature activation receiver) to perform all of the heavy lifting in the page layouts:

  1. Change the target placeholder that is used by the search controls by replacing the Id from TitleInBreadCrumb to a custom placeholder ID CustomSearchControls
  2. Remove the SPNavigation placeholder and all its content from the page layouts. This content placeholder is in the v4 master page already so it’s just a duplicate and causes weird ribbon “jumping”
  3. Add some CSS style rules to hide the left navigation areas of the page because search doesn’t use this area of the page

A  big benefit of doing all that work in a feature receiver is the changes are all reverted and the page layouts are reghosted/uncustomized if the feature is deactivated.

Last point – there are changes that must be made to your custom master page to support these modified page layouts. If you don’t add the following placeholder you’ll get an error. The screen shot below shows what needs to be added (the wrapping <div> isn’t strictly necessary but it allows for any custom styling that might also be needed).

Custom PlaceHolder

And once you upload the sandbox solution to the solution gallery, activate the solution/feature and switch your master page to one with the custom placeholder this is what you will see:

Search with custom v4.master applied

This is a good place to stop. The files are up on codeplex and I hope to do a follow up post soon that explains the source code in detail. If you have any ideas on how to improve this or just general comments please hit me up via a blog comment or on twitter. For now here are links to the files:

  1. Sandbox solution with a site collection feature to do the page layout fix-up described in the post – Search.CustomMasterPageAdapter.wsp
  2. Source code of the feature receiver – PageLayoutFixup.cs
  3. Example custom master page which is just v4.master with the custom place holder added – Custom.v4.master

Christchurch SharePoint User Group Session 26/10/10: SharePoint Development With Visual Studio
October 27, 2010, 10:08 pm
Filed under: 2010, Development, SharePoint, SPUG, Tips & Tricks

I did a joint presentation with Alex Dean at the Christchurch SharePoint User Group which was a brief overview of SharePoint Development 2010 with Visual Studio 2010 and a discussion of some (not all) of the challenges. Alex kicked it off and did a great introduction and then I talked about a few of the problems I have experienced and how they can be worked around.

A big thanks to Alex for coming down from Wellington and doing two presentations. Great effort!

The slides (and of more use the links inside them) are on SlideShare and embedded below:

Code Camp Session: SharePoint 2010 Developer 101
September 7, 2010, 9:31 pm
Filed under: 2010, Development, Presentations, SharePoint

During the recent (August 29, 2010) Auckland Code Camp a buddy of mine Chaks had to pull out of a planned SharePoint 2010 developer session. Luckily Chan and myself were on hand to put together the following session which is a high level overview of SharePoint 2010 Development.

Feedback is always welcome on these sorts of things…but be kind we only had a couple of hours to prepare 🙂

New Zealand SharePoint Conference – Day One Tit-Bits
June 9, 2010, 6:07 pm
Filed under: 2010, NZSPC

The first day of the New Zealand SharePoint Conference is almost over and it has been a really good day with some great sessions and a lot of attendees. I managed to attend a couple of sessions in between being a “booth-babe” and there were some great extra things I didn’t already know that came out. Yes I hear you saying there is a lot of stuff you don’t know…[quiet in the cheap seats!]

SharePoint 2010 has sort of been out for quite some time because the Beta has been available since late last year so this isn’t yet-another-post on SharePoint 2010 and why it will change your life. It’s just a “things I reckon I need to remember” post.


I was lucky enough to see Todd Bleeker do his talk on REST and LINQ and for me a lot of this stuff was pretty interesting and a good refresh on things I had read but maybe not seen. So how easy is REST and LINQ to use? Very easy if your Todd! Anyway the highlights from his session were:

List Improvements

The improvements to SharePoint 2010 lists have been highly publicised for some time but its always good to refresh (I know I said I wouldn’t do this but lists are the lifeblood of SharePoint solutions so I’m making one exception):

  1. Relationships – if your using list lookups (the heart of many SharePoint based solutions) you can now enforce the list relationships between lists(lookups). This is either via restricted delete or cascading delete
  2. Joins – you can join lists when using LINQ to query them
  3. Data integrity – because of 1. you now can have proper data integrity in SharePoint lists that have these relationships defined.

Random Internet Explorer Tip

  1. Internet Explorer – Feed Settings to Help XML “Debugging”

    This was a very handy little tip for when you want to check some RSS or REST output via the browser (Of course the browser would be Internet Explorer right?). By default IE will make the data look nice (via a built in XSL stylesheet I assume) but you want the raw XML. How do you get it apart from a view source? You need to turn off the default behaviour in IE via the screenshot below:




  1. REST is AJAX’ian and nice and snappy for anything where you want no page post-backs. However if you want to do any aggregation (sums, counts etc) via REST then this automatically means it will be done on the client and that’s not really very efficient. What’s the better way? Do those type of “heavy” operations using LINQ so its all done on the server and then the result can be sent to the client. Ahhh…much better!
  2. A point came up from the audience (it was Adam Cogan I think) questioning whether using LINQ with SharePoint can be dangerous if the very likely situation arises that the underlying structure of the lists change (e.g. a user removes a field). The answer from Todd was yes that’s true and therefore you should couple the use of LINQ with SharePoint content types to ensure the fields that make up the base class created/used by the LINQ will not change!
  3. The DataContext – you make one of these with SPMetal which is a command-line tool provided by SharePoint. The bare minimum that SPMetal needs to work with is 2 parameters. One is the site url and the other is that type of class you want it to output (An extension like .CS or .VB) – seriously that sounds too easy!
  4. If you want to see the CAML generated by LINQ then set the .Log property of your DataContext object to a StringWriter and then you can see the CAML!
  5. The IQueryable interface (which is what the SPMetal generate class  implements) lets you output a List<> with the simple method .ToList() – again too easy!


15 Things Every Developer Should Know

Next up was Paul Swider with his 15 things a developer should know about SharePoint. Only 15? No seriously it was a lot of stuff to get through and the tit-bits that came out were:

  1. Start Visual Studio as the Administrator (Run As “Administrator”) if you want debugging to work nicely. This will let you attach to the IIS worker process
  2. Sandboxed Solutions. These were created as a result of developers writing bad code and bringing down the servers/farms. Ha ha I just found that funny enough to post!
  3. A sandboxed solution can be turned into a farm solution by toggling a property in visual studio and redeploying it. Good to know…
  4. The resource governor only works for sandboxed solutions but it would have be a good addition for farm solutions!

There was a question I still need to follow up:

  1. How can you query the term-store and term-sets via a web service? I’m thinking via a DataView web part or jQuery here.

%d bloggers like this: