Tuesday, February 14, 2017

Microsoft Flow, the lazy coder’s alternative to SharePoint web hooks

SharePoint web hooks has made it out from preview and into general availability, and is a great way for applications to act on changes to items in SharePoint. Think workflows where you want to run custom business logic when someone creates or edits an item. For the old-timers a web hook is just a new type of event receiver on the created/updated/deleted events.

The good thing about web hooks is that you can tack them on using either an Microsoft Azure Active Directory application or a SharePoint add-in, using application credentials. This of course is the proper way to do it, so if you are coder-proper, then stop reading now.

So why do it the lazy way using Microsoft Flow?

If you go the route of creating a web hook programmatically you have some plumbing to do up front:
  • Get an administrator to register your AAD app or SharePoint add-in
  • Write code to subscribe the web hook to events on the list/library
  • Write code to re-new the web hook subscription once it expires (max 6 months)
  • Write code to fetch the data of the item which triggered the event
The lazy approach is somewhat a smoother ride, and is what I used at a recent hackathon to get things working fast. The drawback is that Microsoft Flow runs in user context, so you only get events on items you or the account you used to authorize a particular connection have access to – but this might work our just fine for many scenarios. Using a service account is one possibility.

If all you want is access to the data of a created/modified item and want to pass it to a custom API, then using Microsoft Flow makes it very easy. One trigger action which return data for all item fields, and one HTTP action (with swagger if you fancy that) to your custom API with a payload of your choice and you’re set. You can focus purely on the API logic and let Microsoft Flow handle the eventing for you. If you want to handle both created and modified items you need to create two flows.


I'll be fair and say that Microsoft Flow currently does not handle everything and come with some caveats.
  • Currently no support for updating taxonomy field
  • Currently no support for updating lookup fields
  • Currently no support for updating choice fields
  • Currently no support for updating people fields
  • Updated items will have “you” or the account used in the connection to SharePoint as the last modified user
  • Updating a list with more than 12 lookup/taxonomy columns will report as failed, even though they work
As you can see, the weak points for now are on updating items, not getting the values of the item itself - so happy flowing!

Tuesday, February 7, 2017

How to consent to an Office 365 service app

At times you might want to create services which interact with the Microsoft Graph or Office 365 API’s.

If your application has an actual web page you will get prompted for consent when you visit and login. If you have elevated privileges you would tack on &prompt=admin_consent to the URL and then your service can authenticate and do what you need it to.

If you create an Office 365 application entry in Azure AD and have no web application tied to it, this is not automatic.

One approach to get the consent URL is to create a small c# app using the ADAL libraries.

string ResourceId = "https://graph.microsoft.com"; // Microsoft Graph End-point
Uri RedirectUri = new Uri("[APP ID URI]");
ClientId = "[O365 App ClientId]";
ClientSecret = "[O365 App ClientSecret]";

var authenticationContext = new AuthenticationContext("https://login.windows.net/common/");
var url = await authenticationContext.GetAuthorizationRequestUrlAsync(ResourceId, ClientId, RedirectUri, UserIdentifier.AnyUser, "prompt=admin_consent");

If you have a multi-tenant app, you have to login to each tenant using the outputted URL to consent per tenant.

Monday, February 6, 2017

Gaps and differences between a Group 365 Modern Team Site and a plain old Team Site

This post outlines some of the differences between an Office 365 Group Modern Team Site and a plain old SharePoint Team Site as of February 7th 2017.

The gaps may or may not affect you, but from a document management perspective we keep hitting several of the differences in every single projects which often leads to falling back to a plain old Team Site.

As there has been talks of enrolling/upgrading plain old Team Sites into a modern site in a group, I hope the limitations will go away and align more in the future. At Puzzlepart we see the most important ones being able to programmatically configure up pages in a scalable way and having access to synchronized content types.


Saturday, January 21, 2017

How to rename the Title field in a list/library using PnP templates

Took me some testing to get this right, but turned out not that hard. You add a reference to the Title field with the out-of-box id fa564e0f-0c70-4ab9-b863-0177e6ddd247, and then change the display name. In the sample below I’m also using a reference to a language resource as I need support for four languages.

<pnp:ListInstance Title="My List" TemplateType="100" Url="Lists/MyList">
        <Field ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" Type="Text" Name="Title" StaticName="Title" DisplayName="{resource:MyList_MyTitle}" />

Thursday, January 19, 2017

Clarification on automatic managed properties in SharePoint Online

For some time now automatic managed properties in SPO are listed grayed out, with no settings shown. They sort of seem like ghost properties, not usable for anything. Fortunately this is not true.


Displaying no properties does not mean that they are not working as you would expect. The Microsoft SharePoint Escalation Services Team explained it all in a blog post dated August 30th 2016, but it’s not easy to understand. My take is that this was done in order to optimize schema handling in SPO, where there are millions of schemas. They were slowing up, but now at least you can still work with them.

Before you start mapping your crawled properties to new managed properties, see if the automatic ones work as you would expect. The default settings for an automatic managed property (has OWS in the name) are:
  • Queryable
  • Retrievable
  • Multi-value (taxonomy and multi-user fields only)
  • Searchable (taxonomy fields only)
If not, use my rule of 3 below.

Mikaels managed property rule of 3:
  1. Use automatic managed properties if possible
  2. Map crawled properties (the plain ows_columnname ones) to the RefinableXXYY re-usable properties if possible. And do give them an alias for easier management and use
  3. Create a custom managed property as last resort – which is only possible for Text and Yes/No fields.
Shout-out to Joanne Klein for making me blog something which I have just taken for granted :) and to Tarjei for verifying the settings of the auto generated managed properties in an on-prem environment for me. And to Marc Anderson for being the glue!

Friday, January 6, 2017

Retrieving search results from private Groups in Office 365 via REST

By default when you run a search REST query against SharePoint Online results from private Office 365 Groups are not included.

By adding &Properties=’EnableDynamicGroups:true’ to the URL, you will also get results from private groups.

If you are running REST POST requests, add the following to your JSON payload (odata=verbose):


When using CSOM, it seems dynamic groups are included by default.

Sunday, December 25, 2016

Communication & Marketing with Planner - Office 365 Groups Scenarios (2/4)


Ever since Office 365 Groups was released in preview the discussion “when to use what” has been going on between Office 365 Groups and Team Sites. I’ve been opinionated in the debate myself, but instead of listing pro’s and con’s I presented four scenarios at Ignite in Atlanta where Office 365 Groups shows great promise of solving work related problems.

You can get the slides and watch the recording of my session BRK2277 - Learn about Office 365 Groups and how to use them, at the Microsoft Tech Community site. The video is also featured on Microsoft’s support article: Learn about Office 365 groups.

Communication & Marketing


This scenario is about marketing activities and is highly driven my tasks in Planner. Different tasks related to for example news articles, recruiting campaigns, and updating the public web sites are all added to Planner as a place to know what’s in the pipe. Events related to marketing efforts and various important deadlines are added to the Groups calendar. Files related to marketing collateral are stored in SharePoint, and notes on vendors and venues are stored in OneNote. We also receive Puzzlepart relevant tweets and news into the Groups mailbox using the Groups connectors.

Previously we had tasks in Jira, files in Dropbox, and no shared view of monitored news. Moving this to an Office 365 Groups has made a lot of sense in order to get a unified view of marketing and communications efforts.

Other planner based scenarios following the same lifecycle:

  • Development tasks in a kanban style manner
  • Todo lists for a larger group of people

Thursday, December 15, 2016

The Calendar - Office 365 Groups Scenarios (1/4)


Ever since Office 365 Groups was released in preview the discussion “when to use what” has been going on between Office 365 Groups and Team Sites. I’ve been opinionated in the debate myself, but instead of listing pro’s and con’s I presented four scenarios at Ignite in Atlanta where Office 365 Groups shows great promise of solving work related problems.

You can get the slides and watch the recording of my session BRK2277 - Learn about Office 365 Groups and how to use them, at the Microsoft Tech Community site. The video is also featured on Microsoft’s support article: Learn about Office 365 groups.

The Calendar


This scenario is focused around events in time, typically recurring events. The event at a point in time is in focus, and you use Office 365 Groups to support the event. The Group Calendar handles the scheduling of the event, conversations before and after the event can take place using the Group mailbox, and notes during the event are stored in the Groups OneNote. If you want to chat during the event, you could opt-in to use Microsoft Teams.

In my Ignite demo I showed Puzzlepart’s internal recurring event Puzzle Friday, where we every other month go over financial status, give an overview of customer cases, have topic discussions and I present “The Svenson Files”, an aggregate of what has happened in the Office 365 space since last meeting.


As you can see, we use OneNote both for the agenda and all notes taken during the event. We also add follow-up tasks in the OneNote itself. Supporting presentations are stored in the Groups document library, one folder per event occurrence. Then linked into the OneNote. The beauty of this is that we can have one pc hooked up to the projector, which always have all content needed easily available. No switching to my pc for some presentation – it’s all available :) For live demo’s we often create web casts up front, stored in Office Video.
Other calendar scenarios following the same lifecycle:
  • Board meetings
  • Any department/division regular meeting
  • Sprint planning / reviews
If you wanted to improve on the scenario you could build OneNote templates to cover all pages needed per event occurrence.

Wednesday, December 7, 2016

Tip for writing multiple XRANK’s or nested XRANK’s


My colleague Tarjei had a requirement to list items in a particular order on a page. The items were tagged with different phases and he wanted items to be listed in this order:

  • Concept
  • Planning
  • Doing
  • Finishing
  • Realization
  • No phase

The easiest approach I have found doing these types of custom ordering is using XRANK with bulk interval boosts to ensure the order. Pick an interval which suits you. If you need multiple levels of sorting add secondary sorts with intervals less than the major range.

One level sorting:

  • Concept cb=100
  • Planning cb=90
  • Doing cb=80
  • Finishing cb=70
  • Realization cb=60
  • No phase cb=50

Two level sorting:

  • Concept cb=1000
  • Planning cb=900
  • Doing cb=800
  • Finishing cb=700
  • Realization cb=600
  • No phase cb=500
  • Word cb=50
  • Excel cb=40
  • PDF cb=30

Once you have the logic in place you need to write a nested XRANK statement. This often gets confusing with getting parenthesis correct. A Pro tip is to use Freshness Boost Generator in the SharePoint Search Query Tool as a starting point, and then replace your matching and boost expressions as needed. Say you need 6 sorting intervals. Set the constant and max boost values to 0, and add 6 day intervals as seen in the image below. Copy the resulting expression and change the write>{} parts and XRANK(cb=) parts as needed – with all parenthesis intact at the right places.


Thursday, November 10, 2016

Two SharePoint Online search nuggets from Ignite

Ignite is long over, but there were two very useful nuggets in the session BRK2045 – Explore new personalized, intelligence powered search experiences in SharePoint, Delve and O365.

Disclaimer: We don’t know the exact timeline for these features, but they are on the roadmap.

Image result for nugget

  • Content enrichment web service will work for hybrid crawls – This allows you to keep any existing investment in CEWS to work if you switch to indexing content into the SPO index instead of your on-premises index (slide 25)
  • Custom synonyms feature in SPO admin UI – Perhaps a bit cryptic, but this means we will get a thesaurus in SPO search. Huge! (slide 26)

You can find the presentation and video of the session at the Microsoft Tech Community site.