Wednesday 25 February 2015

What's in a .Name? SharePoint Online term set driven custom user profile properties in content search queries

How to utilise term set driven custom user profile properties in your content search web part queries with SharePoint Online


I've been working a lot on the publishing portals side of things recently and as part of this finding ways to drive a more user centric experience within traditional communication portal or intranet environments. For me this is one of the key uptake elements with any comms portal; you have to drive adoption, and if users aren't given some influence on what they see, such that it becomes personalised and relevant then they'll bypass it altogether and hop straight to whatever app or discovery/collaboration area they're looking for within SharePoint.

The problem


Using some very helpful reference material I had already been able to create, map and trigger a re-index of the user profile property store, so I could query the people index and see my new custom property in which I was holding my "personalised" news choices. I had also been able to successfully retrieve and edit that and other properties using JSOM code. Using this I had set up a custom property that maps to a term set (which is the same term set used in tagging articles, enabling matches between preferences and articles in the intranet environment).

The last issue was getting the content search web part query to use that new custom property as a filter on the articles being retrieved (and also using it to XRANK these articles so that they're more visible). I tried various combinations of {User.CustomProperty} and mapping the custom property to a RefinableString value (which of course didn't work, because when querying against the local search index for news articles you can't reference local people index content, the indexes don't talk to each other after all), none of which brought me any joy. Then I went back to the Microsoft documentation here which clearly states that I can use 
{User.<property>}
Any property from the user profile of the user who issued the query — for example, SPS-Interests, including custom properties.
Except that this was definitely NOT working. No filtering was taking place. Frustrating.

I then found the answer I was looking for when reading an extremely useful article by Mikael Svenson on some nice ways to build content search queries. He has an example for expanding multi-value properties into a chain of "OR" operation comparisons (in itself very handy even if I was only experimenting with a single value property at this stage) where he used the query "{|{User.SPS-Responsibility.Name}}"

What is that .Name doing there? Well SPS-Responsibility allows values from multiple term sets, and my custom property was mapped to a term set as well. If you look at the documentation on using terms in content search query then you see that just using the term gives you:
{Term} or {Term.ID} or {Term.IDNoChildren}
GUID of current site navigation node with a prefix of #0 — for example, #083e99dcb-7907-4dc9-abc8-b5614a284f1c. For example, this value can be used to query content of the managed property owstaxIdMetadataAllTagsInfo or owstaxIdProductCatalogItemCategory in a Product Catalog Site Collection.
Whereas using Term.Name gives you:
{Term.Name}
Label of the site navigation node — for example, Audio.
So by using {User.CustomProperty} I was basically trying to compare the GUID of the term to the label of the term (which is what was being returned by the article property). No surprise that it wasn't working as needed then!

The solution


A small alteration to {User.CustomProperty.Name} solved this immediately and the filters sprang into action as expected.


Final note


One additional thing to note here (which may be more or less frustrating depending on your goals) is that whilst JSOM to update user profile properties occurs immediately and content search queries using the {User.<property name>} query variable format use live values, the people search index will always lag behind this, so if you're using a query to retrieve that information locally rather than retrieving it through JSOM your users will see inconsistencies between values. Just something to be aware of, particularly given the hassle that keeping the user profile search index can be sometimes!

- rob

Friday 19 December 2014

SharePoint publishing pages: Prompting the user when they might lose changes

Yes, so first of all apologies for the slightly wordy and not particularly "on point" title for this post - I can't quite how to name it, hence the above...

The problem

Anyway, what this post is about is how to give users creating and editing publishing pages in SharePoint a better experience when leaving a page that is in edit mode. This arose from a customer complaining that if they accidentally (or even purposely) click on the back button, or hit F5 or even click on a link somewhere whilst editing a page they get whisked away without a shadow of a warning meaning that there will be a high chance of losing any unsaved work.

I wanted a quick a dirty solution for this scenario that works in SharePoint Online, which means JavaScript. I'm not claiming that what I'm about to show you is the best possible way to manage this, but it works and the customer was really happy that I was able to throw a solution together for them so quickly.

Wednesday 3 December 2014

SharePoint Online Variations in an existing site and redirecting from the root site

I've had occasion to refresh my knowledge of the variations features in SharePoint Online recently and ran into an 'issue' that I thought I'd (a) share and (b) record for future reference.

There are plenty of decent guides to the basic setup approach for variation labels, etc. out in the ether of the internet already (this is my reference article), so I won't go over that again here, but I had to work through a scenario where an existing site collection, already used as a publishing site, needs to have variation sites created beneath it.

Friday 3 October 2014

SharePoint Online: ensuring sp.js (or any other scrip library) is loaded

Load By Sod to the rescue!


Came across a nice gotcha this afternoon whilst trying to diagnose why some javascript in a content editor wasn't firing correctly on system settings pages (it's a terms and conditions agreement pop-up dialogue that must display the first time a user hits the site whatever their entry page).

Tuesday 24 June 2014

SharePoint Online error - Connect-SPOService : For security reasons DTD is prohibited in this XML document.

The lovely error in full

Connect-SPOService : For security reasons DTD is prohibited in this XML document. To enable DTD processing set the DtdProcessing property on XmlReaderSettings to Parse and pass the settings into XmlReader.Create method. 
At line:1 char:1
+ Connect-SPOService -Url https://XXXXX.sharepoint.com -Credential
adminuser@XXXXX ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Connect-SPOService], XmlExcep
   tion
    + FullyQualifiedErrorId : System.Xml.XmlException,Microsoft.Online.SharePo int.PowerShell.ConnectSPOService

Diagnosing the problem

So I was fiddling around with my new work laptop from home the other day and came across this error. Obviously my first port of call was the universal error solving service known as Google and this threw up a couple of likely candidates:

Tuesday 16 April 2013

#spevo13 Day one round up @spevo13

Sessions attended

What’s new for IT Pros in SharePoint 2013

Useful session covering a wide range of the new stuff in SP 2013. Highlights for me:
  • Shock horror SP2013 needs more RAM 
  • Custom notifications for scheduled maintenance etc. promote themselves to the status bar area in the browser 
  • Self-service site creation can be locked down to the site level and fix it to particular templates 
  • Preview 2013 sites from 2010 point of view 
  • SharePoint machine-based translation services translates documents, pages or entire sites 
  • Cloud-based translation services 
  • Upload a document, translate it, index/search it in any language 
  • Work management service for aggregating tasks across multiple environments: SP, Exchange, Project server, Lync (and anything else you hook into it) 
  • Sparse columns mitigate against reserved column space for zeros and null values - should REALLY assist 

Harnessing SharePoint’s Data Access Technologies

Todd Bleeker gave a great overview of the Deprecated (but still really useful) data access technologies used in SharePoint and some useful pointers regarding the core technology mix for SP2013 and future versions of SharePoint.

The main message was that we’ll still all be having to refer back to deprecated methods for a while yet, not least because the new _api way of accessing SharePoint RESTful services is still without service documentation, so unlike the SP2007/2010 asmx services where you could plug them into Visual Studio and have it list out method calls etc., with the new _api route in SP2013 you are very much shooting blind, which of course will have a knock-on effect for development times.

He spoke a bit about how to extend use of existing asmx services with Marc Anderson’s SPServices (and of course Marc is already looking at whether or not to progress this across to the new _api RESTful model in SP2013), which was useful for anyone in the room not already aware of how you can really improve your use of SharePoint without having to write server-side code.

That was probably the biggest take-away for me – we will all need to be focusing our development skills on the platform agnostic, client-side languages, like JavaScript and combining it with the RESTful service endpoints available in SharePoint 2013. That should be our primary focus when approaching a new development project, not least because more and more clients will be moving to off-premise SharePoint hosting (because as server requirements balloon with each new version of SharePoint and storage needs expand, the argument for on-prem gets harder to make) and in that environment you can forget server code altogether. If you can’t make it work with REST then drop back to CSOM/JSOM and as a ‘final resort’ drop to server OM.

Really, this shouldn’t be much of a shock to anyone who has been doing SharePoint dev for a while. The server OM, whilst relatively stable, has always been a bit of a clunky option to deploy to, maintain and support (I should know, I do far more with state-machine workflows than is healthy). Meanwhile the asmx services were a signal to the new RESTful direction and you can see that Microsoft are going to preference the whole ‘O’ arena (OData, OAuth) going forwards.

Combine knowledge of REST and JavaScript (and its key extension technologies like JQuery, Knockout, SPServices, etc.) with a spot of MVC and WCF for running your own data endpoints to combine with the SharePoint native endpoints.

Workflows with Visual Studio 2012, workflow manager and web services

Andrew Connell’s excellent session was only marred slightly by the failing WiFi at the venue. He ploughed through the technical difficulties with aplomb and still managed to conduct us through the new model of declarative-only workflows in VS 2012/SP 2013, which looks to be powerful and easy to use for the rapid production of complex state-based or sequential workflows.

The first thing to recognise with workflows in SP2013 is that there are substantial infrastructure level changes with the introduction of Workflow Manager 1.0. This is an excellent step forwards and in my opinion this, in conjunction with the new declarative model for workflow development, will mean that workflow (perhaps coupled with search) is the biggest area of positive change in SP2013.

Setup of WFM 1.0 is pretty straightforward, just install that, Service bus and a few CUs and you’re good to go.

Once you’re up and running the VS experience is neat and straightforward. Producing initiation and association forms is leagues apart from previous workflow dev and no, you don’t even need to mess around with correlation tokens and Guids any more.

Rather than cracking open workflow1.cs as we’re all used to, the pure declarative model in SP2013 means no code whatsoever. Let me repeat that, no code in the workflow layer AT ALL. Any code must be abstracted out as a separate business process layer within a workflow (Todd Bleeker’s insistence that we learn WCF pays off again!) and referenced as a web service call. This might sound like a disadvantage, but what it actually does is keep the workflow much more maintainable and focuses workflow development on the workflow, rather than on other business logic areas.

You no longer declare properties or fields, you specify variables or, in the case of custom activity development arguments that can be in/out, and declare how they will change or be updated as the workflow progresses.

It’s now very easy to log the activity of your workflow (to a console app listening to the workflow running in WFM 1.0, for example) and to report its status to the users interacting with it ‘SetUserStatus’ looks to become a staple ‘call out’ for most workflows.

You can also easily (though with one gotcha relating to button generation that I’m sure will be fixed soon) set custom task outcome options and in general the task generation and form association development model is leagues ahead of what we’re used to in SP WF development.

I’ll be writing more posts on WF development in the coming weeks and will be doing a series on ‘you used to do X, now you do Y’ type transition posts from SP2007/10 to SP2013 WF development.

Building the On premise app service

Steve Smith gave us a useful overview of the centrality of the new App model to SharePoint 2013 (virtually every out of the box feature is deployed as an app in SP2013, doc libraries, lists, etc.) and how to build your own App Service, link it to your SharePoint env and add apps.

I’m not going to go into great detail about it here (probably the subject of a new blog post later) but Steve outlined a ten step programme for getting from no app management service to adding your first app to the newly setup app management service.

One of the more interesting parts of the app management service is that it will not only host SharePoint apps but office apps as well. In my environment I already have to deploy office plugins to end users and if they were able to more easily self-manage this through the app management service that could relieve an onerous activity on my part and get them what they need faster and in a more targeted fashion (you can set permissions on a per-app basis to control who can see what). The app catalogue even has the concept of ‘featured apps’ so that your organisation can pick out the things that will help people the most.

Assessing Customer Environments: Preparing to Upgrade or Migrate to SharePoint 2010/2013/365

This was an ‘overview’ type session with some useful info on the common pitfalls encountered when assessing upgrade routes for SharePoint. There are some things that just aren’t possible with SP2013 (no in-place upgrade, as we all know) and others that are new, but not particularly well served (no automatic tool for migrating to Office365, for instance).

The main message was a pretty simple one: there’s no one size fits all solution, you will need a strong business case for the upgrade (because it will involve significant cost) and you’ll need to make sure you’ve investigated all of your options before making the leap, wherever your aiming for.

Dodgy WiFi


Whilst the conference venue and session content has been excellent so far, the WiFi has not. The venues’ facilities in this respect clearly are not up to scratch when it comes to coping with a techie conference and it has materially affected a couple of the sessions I’ve attended (not least Andrew Connell’s excellent session on VS workflow development)

SharePint


Good networking to be had at SharePint and the exhibitors reception beforehand. The conference party tomorrow night promises to be something pretty special, more on that tomorrow!

What's on the board for Tuesday


I'll be attending the following sessions:
  • The Power that is Powershell 
  • Taking your information architecture in a new direction with SP2013 
  • Upgrading, deploying and scaling out SharePoint search 
  • BI with SharePoint 2013/Office365 and Excel 2013 
  • Solving Enterprise search challenges with SharePoint 

- rob

Thursday 18 October 2012

Fix for VS build error: The "FindRibbons" task could not be loaded

I opened an Outlook customisation/plug-in project to do some modifications today and on building received the following delightful error message:

The "FindRibbons" task could not be loaded from the assembly Microsoft.VisualStudio.Tools.Office.BuildTasks, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a.  Confirm that the <UsingTask> declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask

Wow, highlight of my week!

It looks like the issue is related to installing VS2012 side by side with VS2010, it updates the dlls relating to MSBuild, but not the references held in the standard configuration file. The Microsoft forums (via Google) found me my answer in a reply by 'sriram_electric' (thank you!):

For those who encounter this problem, goto C:\Program Files\MSBuild\Microsoft\VisualStudio\v10.0\OfficeTools and open the Microsoft.VisualStudio.Tools.Office.targets file.
Replace all 10.0.0.0 with 11.0.0.0

In my case I had to go to Program Files (x86) as I'm running a 64bit OS, but other than that, and a quick restart of VS, the problem was resolved.

If this doesn't work for you, there are other suggested solutions given in the thread above.

- rob