Tuesday, January 30, 2018

Options to access logos of Office 365 Groups while in SharePoint

Image by Jon Moore on Unsplash

I’m creating a couple of solution these days which will list Office 365 Groups, both public and private, as well as Groups you don’t have access to. Much like the discover function you have in Outlook, except with added filtering on custom metadata for the groups.

Querying for Office 365 Groups using the Microsoft Graph is quite easy, but retrieving an image URL for the groups logo, is inherently hard, especially if you don’t have access to the group.

Friday, January 26, 2018

How to build a great Employee Directory in Office 365 & SharePoint


Lately I’ve been involved in a joint effort with a lot of knowledgable people initiated by Hyperfish to write a guide on how you can creaet an employee directory in Office 365 and SharePoint. The guide covers all things people search in Office 365, and showcase a solution where you can build an alphabetically sorted employee directory for your organization.

Head over to the Hyperfish site and grab your free copy today.

In addition to the people below I’d like to call out my Puzzlepart colleague Trond Øyvind Eriksen who also have contributed by proxy.


Thursday, January 25, 2018

Automating Office 365 Groups Lifecycle/Expiration management

[This post is based on the state of API’s January 24th, 2018]


One of the most awesome preview features today for Office 365 is the ability to set an expiration policy for the Office 365 Groups. Cleaning up old and unused content is something all organizations want, but people are inherently afraid of deleting content and thus become document hoarders. I truly believe this feature might help organizations finally rid themselves of old crap cluttering up all the good stuff.

Note: Groups expiration policy is a premium feature requiring all users in affected groups to have an Azure AD Premium license, and in my opinion this might be a good reason to invest AAD premium.

Currently each tenant support one expiration policy, and you have to decide if this policy should apply to all Office 365 Groups or only to a select number. I expect more policies to be possible in the long run, but one step at a time.

If you opt-in to include all Office 365 Groups in the expiration policy you are in the clear, and really don’t have to read the rest as it’s all automated for you :)

Monday, January 22, 2018

How to make the description text in a URL field searchable in SharePoint

This question came up in a TechCommunity forum, so I figured I’d share it with everyone.

In order for this to work you need to use a site column as this will create a special automatic crawled property which also includes the URL description. Here are the steps needed:

  • Create a new site site column named for example mAdcOWURL
  • Add the column to a list/library
  • Add a new item to the list/library and set the value for mAdcOWURL
  • Wait for indexing to occur (it’s done when you can search for your item)
  • Create a new managed property of type Text
    • Name: mAdcOWText
    • Check searchable and retrievable (nice to check if the property have a value)
    • Map the crawled property ows_q_URLH_mAdcOWUrl
  • Delete the test item, and add the items needed

When the new items are indexed you should get a match on both the terms in the URL as well as terms in the description.


Thursday, January 18, 2018

How to architect long running flows which exceed the 30 day timeout limit in Microsoft Flow

Brown snail in its shell slowly inches across the asphalt

Photo by Alex Blăjan on Unsplash

Microsoft Flow has a built in timeout of 30 days for any running Flow (Logic Apps has 90 days), which for most scenarios is not a problem.

However, there are business processes that might run longer than 30 days, and I’ll address two common scenarios and how to overcome them.

See https://docs.microsoft.com/en-us/flow/limits-and-config for details on Flow limit and see https://docs.microsoft.com/en-us/azure/logic-apps/logic-apps-limits-and-config for limits on Logic Apps.

Scenario 1: Any single action will never last 30 days, but the total Flow might

Let’s imagine you have 5 consecutive actions in your flow, where there is no chance that any of them will run for more than 30 days. For example 5 consecutive approval steps. The way to work around this is to create one flow per approval, and then have them call each other as they go along.

To illustrate the steps I have created two flows. One named “Flow – Initial” and the other “Flow – 2”.

I’ll start with the second flow, as this will be called from the first.

Monday, January 15, 2018

Fetching the last updated items from a large list

A person standing on top of a ladder in the clouds.

I have a list with over 5000 items and on a regular interval I want to query the list to retrieve the last modified items since last time. Typically I will poll every 15 minutes with a CAML query like this:

<View Scope='RecursiveAll'>
                    <FieldRef Name='ContentType'/>
                    <Value Type='Computed'>Item2</Value>
                    <FieldRef Name='Modified' />
                    <Value IncludeTimeValue='True' StorageTZ='TRUE' Type='DateTime'>2018-01-15T14:24:00Z</Value>

This query works fine up till the list reached 5000 items and you will get the infamous item threshold error. In my case there will never be over 5000 updated items in my polling timespan so the fix it quite simple. As I limit on the modified date, add an index for the Modified field from the list settings page. Problem solved, queries will work. And to be sure, create your indexes up front – makes it a lot easier.


An alternative approach [update]

As pointed out by iOnline247 on twitter, an alternative approach is to use the GetChanges API for a list. The GetChanges function can take a specific query in, and you get a change token back which you can use on subsequent calls to get new items since your last call. This would entail storing the token somewhere, which is not a big deal, but will introduce another part to the solution and a little bit of complexity. My current solution is a scheduled powershell script and very stateless. It doesn’t matter if I get an item twice for example.

A third option, which is what I’m moving over to is using Microsoft Flow to trigger on changes on the list.

Photo by Samuel Zeller on Unsplash

Friday, January 12, 2018

Excluding SharePoint Online service accounts from people search

I was almost positive I had written about this before, but seems I haven’t, so here goes.

The user profile store in SharePoint has several service accounts added to it from different Microsoft services running in SharePoint Online. Depending on your solution, these clutter up people search results and you might want to exclude them.

Below is a search for spo* on the SharePoint homepage illustrating these accounts.


In order to remove these accounts you can add the following to your query or query template:

-accountname:spo* -PreferredName:"Foreign Principal"

This will remove all accounts with an accountname starting with spo. If you think this will also remove some of your regular accounts you can do a more granular one:

-accountname:spofrm -accountname:spoapp -accountname:spocrawler -accountname:spocrwl  -PreferredName:"Foreign Principal"

And we just have to hope that Microsoft don’t add more outside of this naming schema.

One thing to note is that you cannot edit the default “Local People Results” result source to make this a global exclusion. You can however create a query rule to append this to every query – but that might break other query rules so I would not recommend this.

This means you might not be able to fix SharePoint Home, but it works anywhere you have a search web part or can control the query being sent over.

Thursday, January 11, 2018

Creating anchor link scrolling on a modern page using the Modern Script Editor Web Part

There are times when you might have some topical links at the top of a page, and once clicked you want the page to scroll down to the right section. This is a perfect use-case for the Modern Script Editor web part. The Modern Script Editor web part is part of the PnP sample web parts project at Github. (A pull request with an updated version to SPFx v1.4 is in the progress of being processed.)

First add a text section, highlight the link part and in the address field type a hash sign and a unique name. In my case I use #scrolltome.


Below the hero web part I add an instance of the Modern Script Editor web part. And this is the easy part. Paste in either of the following HTML snippets and your page will scroll down to this place once the above link is clicked. In the old days anchor tags was used for this, but in these modern times any tag with a unique id works.

  • <a name="something"></a>
  • <span id="something"></span>


The updated script web part has an added property to remove the top/bottom padding of the container, thus making the web part take up zero real estate on the page, perfect for this case.


Once you save your page and test the link this is what it looks like:


If you want a more smooth scroll that’s also possible with your favorite smoothing scrolling script/css.

Monday, January 8, 2018

The sweet spot for using SharePoint site designs and site scripts..

Disclaimer: This post is written based on the current functionality being rolled out, and might not be applicable in the future as the functionality evolves.

….is currently Communication Sites.

Read on if you feel like it :)

Tip for making a Flow easier to read and author

This tip is if you have one logical path in your flow, and also have an “if” statement somewhere. If you are running if/else branches of actions, it won’t help you much.

The following flow has two conditions. If something A, then tweet, and if also something B, tweet some more.


I however find it quickly messy to write a lot of steps inside the “Yes” branches. Instead you can author the same flow with and empty “Yes” branch, and terminate in each “No” branch.


If you then rename your conditions to something useful and collapse them, the flow is much easier to read and author in my opinion.


Wednesday, January 3, 2018

How to get the magic SharePoint site colors


You see them everywhere in SharePoint, these purple, pink, blue and green random colors. I have previously written about these colors, but this time around I’ll offer code so you can generate those colors yourself if you for example are building search based solutions to list out sites.

The below code is assembled based on code I found in the Office UI Fabric for the Persona component and you can use it like this:

import { ColorHelper } from './ColorHelper';
let bgColorHex = ColorHelper.HexCodeFromText("Some Text");
Github Gist Code

Tuesday, January 2, 2018

Follow up discussion on bundle sizes when using Office UI Fabric React components with SharePoint Framework

Microsoft offers great guidance on how to use OUIF with SPFx by taking an explicit dependency on the latest version of the OUIF React package. I also wrote about this previously in August of 2017. And to be crystal clear, the guidance IS THE BEST APPROACH!

You get an explicit dependency with npm i office-ui-fabric-react@latest --save (or any version you care to use), and also remember to remove the reference to @microsoft/sp-office-ui-fabric-core as mentioned in the guidance as the core styles are included in the main npm package.

A simple hello world sample will without using OUIF components be around 10KB in size, and when you add a button component with

import { Button } from 'office-ui-fabric-react/lib/Button';

the .js grows to 179KB. The size is not that bad in itself as it will be served compressed from a CDN, but it illustrates how much the bundle grows by just adding a simple OUIF component.

If you want the smallest bundle size possible and feel like living on the edge there is another option which I’ll outline below. But this approach comes with a huge caveat. Every time Microsoft release a new version of SPFx, you have to re-test and potentially rebuild and deploy your solutions as they can break if Microsoft have updated OUIF React with a breaking change.