Wednesday, 11 February 2015

SharePoint 2013 Search Configuration for Title

If you have had to configure Search in SharePoint 2013, you will know that, post-October 2013 CU, there is a new property included in the Title managed property called MetadataExtractorTitle.  This is an intelligent crawled property which is used to determine the title of a document (primarily) based on the document structure...not the actual metadata someone might attach to the document through SharePoint.

However, if you should need to return the actual metadata value for Title entered by a user, and not what SharePoint thinks the Title is, then the configuration of this is not intuitive by any stretch of the imagination.  Personally, I spent the best part of a few days looking at the configuration and it was only with the assistance of colleague and his contact within Microsoft that the problem was resolved.

The thing with the Title managed property is that it uses a weighting factor to determine which crawled property to use.  Each crawled property within the managed property has it's only "weighting factor" and it's only the combination of this weighting factor combined with where it appears in the order which determines which crawled property is returned by Search for the Title value - it's basically some kind of complex algorithm to determine which property to use. 

I can only thank my colleague Amar for his immense knowledge and his extremely useful contact within Microsoft for this ordering.  I've not seen anything on the web as yet which shows this, so I'm hoping that this will prove useful to not just myself, but to many others.

Here's the order that worked for us (and it has to be this ordering).  Note that MetadataExtractorTitle is pushed right to the bottom - this has to happen, otherwise it nearly always gets used due to it's weighting:


This returned the Title metadata property (not the one determined from the document structure) as well as working correctly for other items returned by Search.

Tuesday, 1 July 2014

_spPageContextInfo in SharePoint 2010/2013

I've used _spPageContextInfo several times over the last couple of years and never thought to blog it myself.  Someone finally had some common sense and decided to put fingers to keyboard and write-up some of the useful properties available on every SharePoint page via this useful JavaScript object.  Here's the link from Sahil Malik:

Wednesday, 12 February 2014

DateTime fields in custom Page Layouts

This was an interesting problem I came across with SP2013 for which, unfortunately, there doesn't appear to be any real resolution.  So, the scenario is this: you develop a custom Page Layout and set up your content types and columns to use within that Page Layout and decide you need a date/time field in the metadata you'll collect.

You promptly add the DateTime field to your custom Page Layout to capture the information and everything appears to be working fine.  However, if you attempt to Save the page using the normal ribbon Save button you get a "save conflict" error, despite no-one else editing the page (and in my case, no-one else using the system at that time).  I tested this in both SharePoint on-premise and Office365 - and both tests showed the same problem.

After some investigation (many hours of it actually) I found one other lonely developer who had experienced a similar problem and suggested using the alternate Save button which, in SP2013, appears between the ribbon and the Suite Bar on the right-hand side (if you're using a right-to-left reading culture).  This little Save button only appears once you're in Edit mode.  Well, I tried it and surprisingly it worked - no "Save Conflict".  I say "surprisingly" as I would have thought these 2 save buttons would share the same common "save" functionality, but apparently that is not the case at all.  It is a work-around, but not exactly very workable as it means users having to understand when to use that button and when not to, and knowing either not to use the "other" ribbon Save button in certain circumstances or to never use it at all.  Rubbish.

There is also a second/third work-around which may or may not be useful, which is to use the "Check-in" option or do a straight "Publish" (if content approval is set up): both not necessarily ideal, but do get around the issue.

Following several questions put up on the Microsoft partner forums, the MS engineer I was discussing the issue with admitted that there did appear to be an issue which I was very happy about at the time as it mean that I hadn't done something stupid in the Page Layout. 

So, I thought I would post this here in case someone else experiences the same problem and if you do, you can at least have some comfort in the fact that it's not entirely your fault!

Friday, 2 August 2013

SharePoint 2013 and the Noteworthy section

If you have added an App to a SharePoint 2013 site you will have seen the "Noteworthy" section which lists what appears to be favourites or well used items.  These Apps are by default Custom List, Document Library and Tasks but additional Apps can be included which are administered via the App settings in Central Administration.  SharePoint Apps are added into a normal SharePoint list and simply ticking the "Featured" property of the corresponding list item means it appears in the "Noteworthy" section (see

However, if you think you can add something useful like a List Template - perhaps one created by your Users who do not want to page through all the available Apps in your farm - then you will be mistaken (unless someone knows better, which is very possible!). 

After doing some research, it does not appear to be possible to use a List Template in the "Noteworthy" section through the normal SharePoint UI and approaches open to normal users as it appears that this section is reserved for "real" Apps and not list templates and the like - therefore to appear in here it has to be an App (I'm willing to be challenged on this point, but I could not see a way to include a List Template in the "Noteworthy" section).

However, after doing some digging, it does appear to be possible to include an item like a List Template under the "Noteworthy" section but only by deploying some customisation which is not always a good thing. 

The page you navigate to when you want to add an App (AddAnApp.aspx) is generated mainly from JavaScript which makes several calls back into itself to get JSON in order to generate the Apps UI.  There are various JavaScript objects created in the page, most notably the "SP.Storefront" object which houses all of the App store front information.

To add an item to Noteworthy is simple enough once you get passed the obfuscation of objects and methods.  The SP.Storefront contains a StorefrontApp object which itself contains a method "get_currentView()".  This method gives me the Management View of the App store front.  This is the object that contains all the view information - what Apps are listed, categories and so on.  One of the properties of the Management View is $L_3 which is an array containing all the available Apps while the property $2i_3 is another array containing only the "Noteworthy" items.

Both of these arrays, $L_3 and £2i_3, contain a number of SPAppMetadata objects which themselves contain a property $2Q_0.  $2Q_0 gives us access to the JSON returned from AddAnApp.aspx for this particular App, so therefore includes more readable properties like ID, Title, Language and so on.  These can be used to identify the App you want to promote into the Noteworthy section, and once identified it's simply a case of adding the item from the $L_3 array into the $2i_3 array.

Of course, that's not the end of the story, adding the object into the array simply means the data is now available, but the UI doesn't update.  To force the UI to catch up, you need to also make a call to SP.Storefront.StorefrontApp.get_currentView().updateUI() and the animation you normally see runs making your new Noteworthy App available.

The obvious question is "how do I get the custom JavaScript into the page?".  Well, the AddAnApp.aspx page uses minimal.master.  Therefore, it's possible that you could add in a delegate control to run some JavaScript in order to update the UI - probably coding it to be specific to the AddAnApp.aspx page rather than running on every page.  You may also be able to use something like a Custom Action using the location of ScriptLink as in SharePoint 2010.

Hope this helps someone out there save some time as it took me a while to work it all out!  There are always better ways to do these things, so if you feel you want to you can let me know if you found another way that works as well.

Monday, 24 June 2013

Public-facing Websites in Office 356

In my research/learning of Office 365, I came across this great article outlining the features available/unavailable in Office 365 when you create a public-facing website.  Covers most of what I had already experienced myself and some things I hadn't, so it's a nice guide to read through:

Of note are some of the "hidden" bits and pieces which still appear to be available - although I'm not sure where this places a site from a support perspective if you do alter some of these "hidden" settings.

Thursday, 20 June 2013

Setting up SharePoint 2013 Apps

What a pain.

After spending almost a day configuring an environment to make SharePoint 2013 Apps work, I can only say that this is a painful process, but one that most developers will have to go through if they want to control an environment they wish to develop against.

I decided that I would plot my steps through this process to help someone else through the same journey, at least it's a map of URLs I visited and information I gathered while on my way through.  Hopefully, it will be useful...but if you have problems after reading and trying everything, don't ask me: I wouldn't consider myself an expert in configuring these things.  I get what I need done and working, then leave well alone so I can concentrate on using and developing against the product!

So here we go.

First of all I was starting with an OOTB SharePoint 2013 single-server installation - no tweaks, no customisations.  The server had Active Directory and Domain Name Server roles set up on it.  The server itself was running on my desktop as a HyperV with Window 2008 R2, and had 8GB of memory allocated to it (half the recommended settings of 16GB which, as you will see, did play a role in some of my problems).

Stage 1:  Getting started

Start: Set up the development environment for SharePoint 2013 -
How to: Set up an on-premises development environment for apps for SharePoint -
Configure an environment for apps for SharePoint (SharePoint 2013) -
Stage 2:  Setting up Apps

At this point I thought that I was on the home straight - everything appeared to run fine with few issues.  Running the PowerShell did throw up an error in the last command in the example (Set-SPAppSiteSubscriptionName -Name "app" -Confirm:$false) which I investigated and found the following article:

Creating SharePoint 2013 Apps – Set the App Domain -

Stage 3:  Server Optimisation

The article seemed to indicate a memory issue so I then went down the road of optimizing my server, reducing the number of Service Applications that were necessary and applications running (I usually leave a PowerShell command window running, alongside Windows Explorer windows and IE, with Visual Studio, but I closed everything except my PowerShell window which I closed and re-opened to release any memory it may have been holding onto):

Optimizing Server Configuration for Development Farm -
Eventually, after shutting down all running applications and trying again, and still receiving the same error, I rebooted and tried again and I got the command to work.  It was time to create my first SharePoint 2013 App.

Stage 4:  My First SharePoint 2013 App (Part 1)

How to: Create a basic SharePoint-hosted app -

So, I followed the example in the article (at this point I hadn't read the comments) but had several issues trying to deploy the project which led me to look at the following pages - the most obvious was the fact that the System Account cannot deploy an App (?):

Error Installing SharePoint 2013 App -
App deployment in SharePoint 2013 RTM -
Error occurred in deployment step 'Install app for SharePoint': The provided App differs from another App with the same version and product ID -
Stage 5:  Memory

I had gone through everything but I was starting experience strange errors, which I considered unrelated to SharePoint specifically:

Compiler Error CS1012 -
Too many characters in character literal? -

Perhaps these too were memory errors, so I decided to run Visual Studio 2012 outside of my DEV HyperV server on my local machine instead, letting the server simply run SharePoint and nothing else.

Stage 6:  My First SharePoint 2013 App (Part 2)
I copied my files across from the server and opened them in Visual Studio 2012 locally, setting up my site path etc correctly and hit F5.  Errors again.  But this time it appeared that there were issues with the Content Database as I was seeing "The content database on the server is temporarily unavailable" in the output window, even though I could hit the site fine.

So that was my next trail to follow:

Install of Apps from visual studio 2012 + The content database on the server is temporarily unavailable -
This led me to this SharePoint 2013 Configure Non-Farm User Account for App Development - which seemed to indicate that insufficient rights were granted to the account I was using.  Despite using an account that was a Site Administrator on my DEV site, the account itself needed certain privileges granted in the Database.  I tried this but it still did not work.
Stage 7:  My First SharePoint 2013 App (Part 3)
Frustration set in.
I then found this article from Microsoft which appears to accompany the March 2013 Cumulative Update: Enable apps in AAM or host-header environments for SharePoint 2013 -  Some of the SQL User Mappings granted to the account I was using differ from the article from I found just before.  So I updated SQL again.
Still not working.  Taking a step back, I read an article about a similar problem which suggested the project had somehow become corrupted.  I looked back through what I had done and realised that it was certainly a possibility, after all, I had copied it from a separate server and assumed it would work.  So I deleted the project and retried it.

Stage 8:  My First SharePoint 2013 App (Part 4) - the Ecstasy

As you can guess from the title here, it was a moment of happiness that my App finally deployed.  It was short-lived, I have admit, as the example in the Microsoft article (How to: Create a basic SharePoint-hosted app - didn't work.  After I scrolled down through the comments of the article, some benevolent being had posted a working example of the JavaScript (App.js) which did sort things out fortunately.  Why Microsoft would put up something so blatantly wrong I don't know, but at least the correct version accompanies it, even if it is in the comments (my advice here is always check the comments: my experience of Microsoft code examples is at about a 50% success rate). 

Final Thoughts

Once things are done, it's done and you don't ever need to worry least that's the theory.  In short, memory did play a part in my problems, so even an 8GB HyperV server isn't quite up to the job of serving up SharePoint 2013 without error, which, in fairness to Microsoft, is lower than their recommended 16GB. 

Hopefully, if you do encounter problems, some of the above will help.  I've seen plenty of people on the 'net struggling with this configuration and I guess any advice or help is useful.

Wednesday, 19 June 2013

Composed Looks in SP2013 and the SPCOLOR file

The reason for this post is to explain some of the SPCOLOR attributes and their purpose - where they are used and what for.  A colleague and myself put this together (so thanks to Olly for the majority of this work) and I'm sure some people may be able to add more details to some of the explanations below.

While Composed Looks in SharePoint 2013 have opened up a whole new way to design SharePoint it comes with some serious limitations.  Heather Solomon's blog on "When to use a SharePoint 29013 Composed Look" is an excellent starter to understand some of these limitations and explains things much better than I could. 

Microsoft have also put out some pretty decent articles on Composed Looks ( is a good starting point) but the main article has one bit missing IMHO: there are no updates to the SPWeb Master Page properties (MasterUrl and CustomMasterUrl). 

So here is the file: please feel free to cut and paste into something more readable and use as a starting point for your own exploration.

<?xml version="1.0" encoding="utf-8"?>
<s:colorPalette isInverted="false" previewSlot1="BackgroundOverlay" previewSlot2="BodyText" previewSlot3="AccentText" xmlns:s="">
    When setting colour codes, use HEX values. Opacity can be added on to these values. An example of this would be: E5FFFFFF.
    The first 2 ('E5'FFFFFF) characters of that code are the opacity, resulting in a transparent white.
        Text Colour Styles
    <s:color name="BodyText" value="444444" /> <!-- Normal body text. -->
    <s:color name="SubtleBodyText" value="777777" /> <!-- Body text that must be lighter than normal. An example is metadata text. -->
    <s:color name="StrongBodyText" value="262626" /> <!-- Body text color for text that must stand out from normal body text. -->
    <s:color name="DisabledText" value="B1B1B1" /> <!-- Disabled text. For example, unavailable items in menus. -->
    <s:color name="SiteTitle" value="262626" /> <!-- The text color of the page title. -->
    <s:color name="WebPartHeading" value="444444" /> <!-- Text color for Web Part headings. -->
    <s:color name="ErrorText" value="FF0000" /> <!-- The main error color that is used for error text, borders, and backgrounds, as needed. -->
    <s:color name="AccentText" value="f44c0a" /> <!-- Text color for accented body text. -->
    <s:color name="SearchURL" value="358700" /> <!-- Text color for the URL found in search results. Also used to highlight new items or successful status notifications. -->
        Hyper Link Styles
    <s:color name="Hyperlink" value="f44c0a" /> <!-- Text color for hyperlinks. -->                            
    <s:color name="Hyperlinkfollowed" value="4F6DBB" /> <!-- Text color for followed hyperlinks. -->
    <s:color name="HyperlinkActive" value="1789C1" /> <!-- Hyperlink color when pressed. -->
        Command Links
    <s:color name="CommandLinks" value="666666" /> <!-- Large command links that must be a bit lighter than body text because of their size. -->
    <s:color name="CommandLinksSecondary" value="262626" /> <!-- Command link color for links that are smaller, and therefore have a stronger color to stand out. -->
    <s:color name="CommandLinksHover" value="f44c0a" /> <!-- Command link color on hover and color of "Add an App" and "New subsite" icons -->
    <s:color name="CommandLinksPressed" value="1789C1" /> <!-- Command link color when pressed. -->
    <s:color name="CommandLinksDisabled" value="B1B1B1" /> <!-- Command link color when command link is disabled. -->
        Background Styles
    <s:color name="BackgroundOverlay" value="E5FFFFFF" /> <!-- The main background color that is visible between the optional background image and the page content. -->
    <s:color name="DisabledBackground" value="FDFDFD" /> <!-- Background for disabled elements such as browser controls, for example, input box or select box (except buttons). -->
    <s:color name="PageBackground" value="FFFFFF" /> <!-- The background color of the page. Appears behind the optional background image. -->
    <s:color name="HeaderBackground" value="D9F8F8F8" /> <!-- The background color for the header area of the page. -->
    <s:color name="FooterBackground" value="CBEFEFEF" /> <!-- The background color for the footer area of the page. -->
    <s:color name="SelectionBackground" value="7F95D3F1" /> <!-- The background color for selected list items and drop-down menu items. -->
    <s:color name="HoverBackground" value="65CDE9F7" /> <!-- The background color for list items and drop-down menu items on hover. -->
        Border Styles
    <s:color name="RowAccent" value="f44c0a" /> <!-- The accented left border on selected list items. -->
    <s:color name="StrongLines" value="78C8EE" /> <!-- Borders for browser controls on hover. -->
    <s:color name="Lines" value="ABABAB" /> <!-- Borders for browser controls. -->
    <s:color name="SubtleLines" value="E5E5E5" /> <!-- Subtle border color. For example, gridlines for inline editing. -->
    <s:color name="DisabledLines" value="E1E1E1" /> <!-- Border color for disabled browser controls such as input boxes and select boxes. -->
    <s:color name="AccentLines" value="3BAFE7" /> <!-- Focused border color for selected browser controls. -->
    <s:color name="DialogBorder" value="E5E5E5" /> <!-- Dialog box border color. -->
        Navigation Styles
    <s:color name="Navigation" value="666666" /> <!-- Text color for horizontal and vertical navigation items. -->
    <s:color name="NavigationAccent" value="f44c0a" /> <!-- Text color for a selected horizontal navigation item. -->
    <s:color name="NavigationHover" value="f44c0a" /> <!-- Navigation text color on hover. Applies to top navigation, and to Quick Launch in horizontal mode. -->
    <s:color name="NavigationPressed" value="1789C1" /> <!-- Text color of navigation item when pressed. Applies to top navigation, and to Quick Launch in horizontal mode. -->
    <s:color name="NavigationHoverBackground" value="65CDE9F7" /> <!-- Background color of Quick Launch items in vertical mode on hover over the navigation item. -->
    <s:color name="NavigationSelectedBackground" value="C6EFEFEF" /> <!-- Background color of Quick Launch items in vertical mode after the navigation item is selected. -->
        Emphasis Styles
    <s:color name="EmphasisText" value="FFFFFF" /> <!-- The text color that appears on top of emphasis background. -->
    <s:color name="EmphasisBackground" value="f44c0a" /> <!-- The accented background color that appears directly behind emphasis text and the "Site Content" icons -->
    <s:color name="EmphasisHoverBackground" value="1789C1" /> <!-- Background color on hover, for elements that are using emphasis background. -->
    <s:color name="EmphasisBorder" value="1789C1" /> <!-- Border color for elements that are using emphasis background. -->
    <s:color name="EmphasisHoverBorder" value="1375A5" /> <!-- Border color on hover for elements that are using emphasis background. -->

        Hyper Link Styles
    <s:color name="SubtleEmphasisText" value="666666" /> <!-- Text that appears on top of subtle emphasis background. -->
    <s:color name="SubtleEmphasisCommandLinks" value="262626" /> <!-- Command link color for links that appear on top of subtle emphasis background. -->
    <s:color name="SubtleEmphasisBackground" value="C6EFEFEF" /> <!-- Background that appears directly behind subtle emphasis text. -->
        Top Bar Styles
    <s:color name="TopBarText" value="333333" /> <!-- Text and glyph color for the welcome menu, quick access toolbar icons, and closed ribbon tabs. -->
    <s:color name="TopBarBackground" value="CBEFEFEF" /> <!-- The background color for the top bar, which is seen below and to the right of the suite navigation. -->
    <s:color name="TopBarHoverText" value="333333" /> <!-- Text and glyph color on hover for the welcome menu, quick access toolbar icons, and closed ribbon tabs. -->
    <s:color name="TopBarPressedText" value="333333" /> <!-- Text and glyph color for when the welcome menu, quick access toolbar icons, or closed ribbon tabs are pressed. -->
        Header Styles
    <s:color name="HeaderText" value="444444" /> <!-- The base text color for anything in the header area. -->
    <s:color name="HeaderSubtleText" value="777777" /> <!-- Helper text for the search box when in the header area. -->
    <s:color name="HeaderDisableText" value="B1B1B1" /> <!-- Text for the search box, if the search box is disabled when in the header area. -->
    <s:color name="HeaderNavigationText" value="666666" /> <!-- Base text color for navigation links in the header area. -->
    <s:color name="HeaderNavigationHoverText" value="f44c0a" /> <!-- Text color for navigation links in the header area when you hover over the link. -->
    <s:color name="HeaderNavigationPressedText" value="1789C1" /> <!-- Text color for navigation links in the header area when you press the link. -->
    <s:color name="HeaderNavigationSelectedText" value="f44c0a" /> <!-- Text color for navigation links in the header area after the link is selected. -->
    <s:color name="HeaderLines" value="ABABAB" /> <!-- Search box lines when the search box is in the header area. -->
    <s:color name="HeaderStrongLines" value="78C8EE" /> <!-- Search box lines on hover when the search box is in the header area. -->
    <s:color name="HeaderAccentLines" value="3BAFE7" /> <!-- Search box lines on focus when the search box is in the header area. -->
    <s:color name="HeaderSubtleLines" value="C6C6C6" /> <!-- Subtle lines found inside the header area. Not used in default CSS. -->
    <s:color name="HeaderDisabledLines" value="E1E1E1" /> <!-- Search box lines if the search box is disabled when it's in the header area. -->
    <s:color name="HeaderDisabledBackground" value="FDFDFD" /> <!-- Search box background if the search box is disabled when it's in the header area. -->
    <s:color name="HeaderFlyoutBorder" value="D1D1D1" /> <!-- Border for drop-down menus when originating from the header area. -->
    <s:color name="HeaderSiteTitle" value="262626" /> <!-- Text color for the site title when in the header area. -->

        Suite Styles
    <s:color name="SuiteBarBackground" value="f44c0a" /> <!-- Background color for the suite navigation. -->
    <s:color name="SuiteBarHoverBackground" value="63BFEC" /> <!-- Background color on hover for the suite navigation. -->
    <s:color name="SuiteBarText" value="FFFFFF" /> <!-- Text and glyph color for the suite navigation items. -->
    <s:color name="SuiteBarDisabledText" value="D3D3D3" /> <!-- Text and glyph color for disabled suite items. Not used in default CSS. -->
        Button Styles
    <s:color name="ButtonText" value="444444" /> <!-- Text color for buttons. -->
    <s:color name="ButtonDisabledText" value="B1B1B1" /> <!-- Text color for disabled buttons. -->
    <s:color name="ButtonBackground" value="FDFDFD" /> <!-- Background color for buttons. -->
    <s:color name="ButtonHoverBackground" value="D9EFFA" /> <!-- Background color for buttons on hover. -->
    <s:color name="ButtonPressedBackground" value="9ED7F2" /> <!-- Background color for buttons while pressed. -->
    <s:color name="ButtonDisabledBackground" value="FDFDFD" /> <!-- Background color for disabled buttons. -->
    <s:color name="ButtonBorder" value="ABABAB" /> <!-- Border color for buttons. -->
    <s:color name="ButtonHoverBorder" value="9ED7F2" /> <!-- Border color for buttons on hover. -->
    <s:color name="ButtonPressedBorder" value="63BFEC" /> <!-- Border color for buttons while pressed. -->
    <s:color name="ButtonDisabledBorder" value="E1E1E1" /> <!-- Border color for buttons that are disabled. -->
    <s:color name="ButtonGlyph" value="666666" /> <!-- Glyph color for a glyph that appears in a button. -->
    <s:color name="ButtonGlyphActive" value="444444" /> <!-- Glyph color on hover, for a glyph that appears in a button. -->
    <s:color name="ButtonGlyphDisabled" value="B1B1B1" /> <!-- Glyph color for a disabled button. -->
        Title Styles
    <s:color name="TileText" value="FFFFFF" /> <!-- The text that appears on top of the tile background overlay. -->
    <s:color name="TileBackgroundOverlay" value="99000000" /> <!-- The background overlay color for tiles. -->
        Rich Text Editor Accents
    <s:color name="ContentAccent1" value="f44c0a" /> <!-- The first accent color that a user can select from the Rich Text Editor color picker. -->
    <s:color name="ContentAccent2" value="FF0097" /> <!-- The second accent color that a user can select from the Rich Text Editor color picker. -->
    <s:color name="ContentAccent3" value="996600" /> <!-- The third accent color that a user can select from the Rich Text Editor color picker. -->
    <s:color name="ContentAccent4" value="F09609" /> <!-- The fourth accent color that a user can select from the Rich Text Editor color picker. -->
    <s:color name="ContentAccent5" value="A200FF" /> <!-- The fifth accent color that a user can select from the Rich Text Editor color picker. -->
    <s:color name="ContentAccent6" value="00ABA9" /> <!-- The sixth accent color that a user can select from the Rich Text Editor color picker. -->