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
    image
  • Wait for indexing to occur (it’s done when you can search for your item)
  • Create a new managed property of type Text
    image
    • 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.

image

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'>
    <Query>
        <Where>
            <And>
                <Eq>
                    <FieldRef Name='ContentType'/>
                    <Value Type='Computed'>Item2</Value>
                </Eq>
                <Geq>
                    <FieldRef Name='Modified' />
                    <Value IncludeTimeValue='True' StorageTZ='TRUE' Type='DateTime'>2018-01-15T14:24:00Z</Value>
                </Geq>
            </And>
        </Where>
    </Query>
    <RowLimit>5000</RowLimit>
</View>

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.

image

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.

image

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.

image

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>

image

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.

image

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

scroll

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.

image

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.

image

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

image

Wednesday, January 3, 2018

How to get the magic SharePoint site colors

image

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.

Friday, December 8, 2017

Better security defaults for Office 365 Groups and document collaboration

image

After working with Office 365 Groups for a while now and helping customers tailor their Office 365 Groups, I have developed a mantra I call Better Defaults. This involves exchanging default settings for more sensible ones – at least in my opinion.

One of the strengths of a SharePoint site is the ability to set very granular permissions. This security strength is also a pain for end-users. Over the years teaching classes and helping customers, getting to grips with AD groups, SharePoint Security groups, permission levels, and all the places you can set them is one of the top three hardest topics. When you tack the simple owner/member permission structure of an Office 365 Group on top of a SharePoint site, it does not help the confusion.

In this post I’ll offer two tips for better defaults regarding content access, one for public groups and one for private groups.