Thursday, April 12, 2018

Expose values from an existing InfoPath field to a SharePoint field


Photo by adrian on Unsplash

Ok, I know InfoPath is not the future and all, but I happen to have one client which has an old InfoPath solution for reporting incidents at their facility. I have previously migrated this from SharePoint 2007 to 2013, which involved some XML manipulation in the process, and I did spare you a blog post on this :-)

Either way, the lists of incidents which goes back years have now been hooked up to PowerBI via the on-premises gateway, so the customer is slowly taking the leap to the cloud.

And, turns out, the date field which has the date of the incident was never exposed as a SharePoint field, a field which is pretty nice to report on for incidents.

I fired up SharePoint designer, promoted the field in question and re-published the InfoPath form. This ensured all new items would have a date in the incident date field, but all existing items were still blank. So how could I in the easiest way possible get the value from the XML files promoted to the SharePoint field? Turns out it was very very very easy.

It was a matter of looping over all list items and running SystemUpdate() on them. This ensured modified date and modified by fields were not changed, but the value got populated.

Below is my PnP PowerShell snippet which saved the day.

Get-PnPListItem -List "Incidents" |% { $_.SystemUpdate();$_.Context.ExecuteQuery() }

Wednesday, April 11, 2018

Free status bar extensions for modern SharePoint sites

Did you think we were being lazy over at Puzzlepart? Think again. This time we give you a status bar top extensions.

statusbar

Get the code at https://github.com/Puzzlepart/spfx-solutions/tree/master/Pzl.Ext.StatusBar

The above image shows two notifications, one which checks if the Office 365 Group support external member or if the site allows sharing with external users. The other highlights a classification setting if it’s a specific value, in this case sites with classification Confidential or above will show a status message.

Technically it consists of three extensions, one base extension doing the rendering, and then you can add any number of other extensions which render a message based on the logic you decide. If there are nothing to render, then the status bar will not render.

I’m not saying the communication between the parts is the most graceful one, but it’s a pattern we are trying out – and it works, and you can use the base renderer with your own logic. Take a look at the two samples provided and you should figure out how to create your own. The clue is the messageId parameter which has to be the same for all extensions, to make them aware of each other.

Get the code at https://github.com/Puzzlepart/spfx-solutions/tree/master/Pzl.Ext.StatusBar

Tuesday, April 10, 2018

Working with Hub Sites and the search API


Photo by Sunaina Kamal at Unsplash.

Hub sites are a nice way to create a virtual two level site hierarchy without using sub sites. An administrator will nominate a site as a hub site, and then other sites can associate themselves to this hub. By associating a site to a hub the site will inherit the navigation and the visual look of the hub itself, ensuring a consisting look and feel. Also items from associated sites will surface in search at the hub level (as long as you have read access to the item).

image

Note: The hub site feature is currently in preview and only available for target release tenant at the time of writing.

After playing with hub sites you might want your favorite developer to create something for your hub sites, and this is where the search API is handy.

Thursday, March 29, 2018

Quick tip: easily test SharePoint Framework web parts on modern pages (addendum to Waldek’s post)

image

Did you know that you can easily test your SharePoint Framework web parts on modern pages?

If there’s one guy who know, it’s my friend Waldek Mastykarz. Today he had a post outlining how you can debug/test SPFx web parts on a real modern page, not the SharePoint workbench.

Wednesday, March 28, 2018

Optimizing meshing with Cisco Meraki access points

image

I have had a Cisco Meraki MR-33 hooked up for a little while, which is positioned pretty centrally in an L shaped space. The issue is that the building is old with lots of brick walls. In the far room of the long leg of the L there is about 2 meters of space which gets pretty spotty connection. Not a huge deal, but enough to irritate :)

Setting up a second access point via cable is not a viable option so I decided to mesh two access points instead. The setup was easy, but the throughput was not amazing, averaging around 15mbit/s, and lower. You might think this is ok as we’re meshing, but the good thing is that it can be improved.

Note: Read the Meraki guide Manually Changing Channels in a Mesh Network for information on how you can change the channel used for meshing.

By default when you have auto channels for both the 2.4GHz and the 5Ghz radio, the 5GHz channel will be set to the same channel for both devices, and this is used for meshing. Having band steering on, where clients also use 5GHz, this will greatly reduce the speed.

What I did was this.

  • I set a dedicated channel for the 2.4GHz radio – to allow meshing to happen on the 2.4GHz radio, which also travels better though the brick walls.
  • I set the 5Ghz radio to automatic.
  • I use band steering, leading clients to the 5GHz radio.

This setup “ensures” clients use 5Ghz, while the mesh traffic have the full bandwidth itself on the 2.4GHz radio. Now my throughput is pretty consistent around 55mbit/s.

image

Office 365 logo kit available at Fasttrack for partners/customers

Ever in the need to use Office 365 icons and wonder how they can be used? Head over to https://fasttrack.microsoft.com/dl/brandingkit (requires login) and download the Microsoft Office 365 Branding Toolkit today.

The downloaded zip file has icons in different formats. Below are samples of the 256x256 icons, and the file only contains .png files.

image

image

Monday, March 26, 2018

Updated Modern Script Editor Web Part with fix for AMD modules and exposing _spPageContextInfo

image

The web part haven’t change much, but the following configuration options are now available:

  • Keep or remove padding on the web part zone – useful if you have script which does not output any markup.
  • Set the _spPageContextInfo variable – useful if you have old scripts using this variable on classic SharePoint pages.

I have also fixed the code so that it won’t fail when loading AMD module scripts – meaning the scripts will not detect themselves as module scripts, but load globally instead.

You can get the code from https://github.com/SharePoint/sp-dev-fx-webparts/tree/master/samples/react-script-editor.

SharePoint Query Tool v2.8


Image by Emily Morter on Unsplash

This is a short one, and not much has changed. Basically I removed the old browser based SharePoint Online login method as it caused too much friction on Windows 10 machines. And I fixed an issue where all properties did not show when using the new SharePoint Online login method.

Get v2.8!

Friday, March 23, 2018

Two approaches to applying a modern theme using PnP


Photo by Ash Edmons on Unsplash

Modern sites are no longer using the old theming engine directly with .sptheme, .spcolor and .spfont files. Instead you can use the Theme Generator tool to get your colors the way you want them, and this is what this post will focus on, how you can automatically set the right colors using PnP. The post has two samples, one using PnP PowerShell and one using a PnP Provisioning template.

Monday, March 19, 2018

A workaround for saving hi-res photos from PowerApps to SharePoint

Saving photos or images from PowerApps to SharePoint is not easy, but there are workarounds using for example Flow to get this to work as I’ve written about previously. The caveat with this approach is that when using the camera control you won’t get full resolution on the images you take, but a scaled down version – and adding Flow to the mix increased complexity.

With the recent release of supporting attachments with SharePoint lists in PowerApps it’s now possible to get those high resolution photos into SharePoint. But, it’s not straight forward. Even though it’s possible you should think it through before going full on production with this.

Note: This post is written based on testing on iOS.

Uploading photos is a common ask when using PowerApps on mobile device. You might create a reporting application of sorts which supports adding photos as documentation. My first thought was to utilize the new attachment support, pick the camera as input and be done with it. Turns out I should stop believing in fairy tales when a feature is just released :). When tapping the “Attach file” link, you get a dialog to browse your iCloud Drive, not an option to tap into the camera. Which makes sense as you need an attachment filename. This means we cannot use the default add attachment functionality.

20180318_124151000_iOS

What I came up with was using the “Add picture” control with a custom collection, and then binding the forms attachment control value to this collection. You also need to reset the form after you modify the collection in order for the change to be picked up in the control (which is needed for it top be submitted). The reset has a timing issue, so I had to add a timer control which reset’s the form every 1 second. It’s all in a days works of duct tape.

Oh well.. let’s build the application, and you will see for yourself.

Friday, March 16, 2018

How to display images from a SharePoint library in PowerApps

[Update: As mentioned in the comments by Paul Culmsee, this only works in the web version of PowerApps - not on devices. To make it work on devices take a look at his posts for a proxy workaround]

A while back I wrote a post about how to save images from PowerApps to SharePoint via Flow. Today  I got a comment asking how you can show images sored in a SharePoint library in a PowerApp. Turns out it’s not hard at all.

I first created a new document library named “Images” in a SharePoint site and uploaded two images.

image

Within your PowerApp add a new data source, and manually type in the name to the library containing your files, in my case “Images” and hit “Connect”. The manual typing is the crux to make this work.

image

Next add a gallery to your app and bind it to the Images data source. For the Image control, change the binding to be ‘{Link}’ and you should see your images showing up in the gallery.

image

Happy PowerApping!

How to: Embed the Yammer All Company feed on a modern page in SharePoint Online

This is not hard at all these days, as the Modern Yammer web part recently got updated and allows you to pick “All Company” as the feed to display.

First add the Yammer web part to your page.

image

Then search for “All Company” and pick it. Previously you had to paste the link to a group, but this search experience makes it a lot easier indeed.

image

Friday, March 2, 2018

My NACS2018 presentation about taking control of Office 365 Groups creation and configuration using Azure Functions and Flow

Here’s my presentation and don’t hesitate to contact me if you want to learn more.

Wednesday, February 28, 2018

You don’t get to MVP without making a few enemies

MVP-enemies_thumb1
Cover by Kim Damsleth (Puzzlepart)

If you thought becoming an MVP is as easy as 1-2-3, think again – my story is all about pushing aside those who have been in my way and claiming what is mine! Don’t like it? Tough luck – I’m here to stay!

Tuesday, February 27, 2018

One way to figure out which SharePoint Online domain you are on with an unlicensed user

Ok, someone created an account for you on their Office 365 tenant for testing, and gave it no licenses what so ever. Yet, they did grant you permissions to access SharePoint Online. So, how do you find out what the SharePoint domain is? Because you have no apps in the app launcher or search box to help you out.

We mulled this over at our Puzzlepart dev chat channel, and Ole Kristian came up with the first solution:

Once logged into office.com, crank open dev tools in your browser and type:

navBarData.SPO_RootSiteUrl

This will yield the sharepoint domain name :)

image

Do you know a different way?

Monday, February 26, 2018

Fixing the “this website doesn’t support embedding” error when using the preview Kindle web part in a modern page – read the manual :)

I decided to try out the Kindle preview web part, previewing my own Search Queries Explained book. When pasting the link I was presented with the following error:

image

And as the error message says, use the embed code instead of just the link. But would be nice if it managed to wrap this automatically, no? :)

image

When pasting the full <iframe> link it works as expected.

image

Alternative way to solve the issue where a SPFx v1.4.0 web part don’t show when upgrading.

In SPFx v1.4.1 there was an important bug fix which was introduced in SPFx v1.4.0. If you created a web part which was manually installed on a site collection, upgrading the web part would result in the web part not showing. The issue noted on the release notes for v1.4.1 says in order to fix this do the following:

  1. Remove all instances of existing SharePoint Framework solutions from site level
  2. Remove SharePoint Framework solution from app catalog
  3. Upload new SharePoint Framework solution built with 1.4.1 version to your app catalog
  4. Install SharePoint Framework solutions back to sites.

You don’t have to uninstall the solution, but can follow these steps instead:

  1. Upgrade your web part to SPFx v1.4.1 and bump the version number of the part in package-solution.json and package it.
  2. Navigate to https://<tenant>.sharepoint.com/sites/<AppCatalogSite>/Lists/ComponentManifests and remove the entry for the web part in question.
  3. Upload the updated web part to your app catalog, overwriting the old one, and ensure the app is checked in, if it becomes checked out.
  4. Upgrade the web part package on the site collection(s) where used (site contents, classic view, about on the part, then “Get it” to get the latest version.
    image
    image

Unfortunately there is no easy way to see all sites which have installed a particular SPFx v1.4.0 web part, so you have to loop over all sites in order to ensure they are all working as expected.

Tuesday, February 20, 2018

Automatically set an Office 365 Group Logo - Another free SharePoint Framework extension from Puzzlepart

image

Photo by Mikael Svenson

If you haven’t caught on already, at Puzzlepart we love sharing our small quirky workarounds. This time around it’s a run-once extension which will set the logo for an Office 365 Group when a group owner visits the site for the first time.

Get the extension code!

Monday, February 19, 2018

Minimal path to awesomeness when moving Microsoft Graph calls to SharePoint Framework v1.4.1


Image by Jeremy Bishop at Unsplash

Phew.. that title was a mouthful. When SPFx v1.4.1 was released the other day, the GraphHttpClient object in SPFx was deprecated in favor of either the AadHttpClient object or the MSGraphClient object. If all you care about is Microsoft Graph calls, then they do pretty much the same, except the MSGraphClient object allows a fluent API to build up your queries with selects, sorts and filters, whereas the AadHttpClient takes a handcrafted URL.

So, from a minimal path perspective the AadHttpClient makes more sense as it takes complete URL’s, and we don’t have to break up the call into a fluid syntax. Also, the MSGraphClient is currently in preview.

Note: If your tenant is not on Targeted Release (TR), you will not be able to grant the needed graph scopes using the SharePoint Admin UI or with SPO Management PowerShell. Uploading the app package will also not work on a normal tenant so be patient.

Thursday, February 15, 2018

Programmatic nuance in .Net and PowerShell which can wreck havoc


Photo by David Kovalenko at Unsplash

Took me an hour or so to figure out why something I had ported from C# to PowerShell was not working, and the culprit is how casting of decimals to bytes work.

In .Net: (byte)4.6 = 4, meaning it truncates

In PowerShell [byte]4.6 = 5, meaning it rounds up

The solution is to use [Math]::Floor instead in PowerShell, which of course works fine in .Net as well.

Tuesday, February 13, 2018

How to properly use the “Get Manager” Flow action with a SharePoint list

A confident man in a blue blazer
Photo by Olu Eletu at Unsplash.

This is a short one and quite easy. When you create an item in SharePoint the unique identifier for a person field is the claim, while the Get Manager action takes a UPN (user prinipcal name).

image

For Office 365 they are almost equal. The claim is actually the UPN + a claim prefix.

UPN: john@contoso.com
Claim: i:0#.f|membership|john@contoso.com

If you have a flow triggering on a SharePoint list, you would enter the following expression for the UPN field to strip off the prefix from the claim.

replace(triggerBody()?['Editor']?['Claims'],'i:0#.f|membership|','')

image

Sure you can use the e-mail address which usually match the UPN, but you would be surprised how often multiple accounts have the same e-mail address - admin accounts, test accounts etc. So using a unique identifier is always a better approach compared to the e-mail address.

Monday, February 12, 2018

Validating a number format in SharePoint – divide and conquer formulas

A modern white chair at a table with a laptop, a notebook and a calculator

Photo by Oliver Thomas Klein at Unsplash.

Validating input in SharePoint is nothing new, but I haven’t dug much into this over the years. This time around I have a list where one of the fields takes a case number. The case number should be on the format:

0000/000000 <- four digits, a slash, then 6 digits.

Using regular expression this would have been a breeze - \d{4}\/\d{6} , but that’s not an option in SharePoint. Using the official formula documentation as a lookup I ended up with the following formula. I’ve split it over multiple lines and added comments for readability, so remember to remove the comments before using. Depending on your locale you might have to use comma instead of semi-colon.

Make note of the +0 which is workaround to convert text to a number.

AND(
    LEN([Case Number])=11;                # Total length is 11 characters
    MID([Case Number];5;1)="/";           # Fifth character is a slash
    ISNUMBER(MID([Case Number];1;4)+0);   # First four characters is a number 
    LEN(TRIM(MID([Case Number];1;4)))=4;  # First four characters has no spaces
    ISNUMBER(MID([Case Number];6;6)+0);   # Last six characters is a number
    LEN(TRIM(MID([Case Number];6;6)))=6   # Last six characters has no spaces
)

Validation is entered at the columns settings.

image

And here I only have 5 digits at the end, which does not validate.

image

Monday, February 5, 2018

Appending field values into a string in Microsoft Flow

An aerial shot of brightly-colored jigsaw puzzle pieces

Photo by Hans-Peter Gauster on Unsplash

I’m working on implementing a Flow which triggers on a SharePoint list. This list has a managed metadata column where you can select multiple terms. In my Flow I want to append the terms into a single string which I’m persisting on my Microsoft Graph schema extension techmikael_GenericSchema.

The approach I’ll outline does not only apply to taxonomy fields, but for any input which has an array of objects. Below is a sample object array.

[
  {
    "TermGuid": "74c34307-80e8-4e21-a63b-81337e369a5c",
    "WssId": 29,
    "Label": "Term A",
    "Path": null,
    "Value": "Term A|74c34307-80e8-4e21-a63b-81337e369a5c"
  },
  {
    "TermGuid": "db79ec09-34ad-4c60-8f4c-d41248ee09ac",
    "WssId": 450,
    "Label": "Term B",
    "Path": null,
    "Value": "Term B|db79ec09-34ad-4c60-8f4c-d41248ee09ac"
  }
]

The output should pick the Value property and join them together with a semicolon like this:

Term A|74c34307-80e8-4e21-a63b-81337e369a5c;Term B|db79ec09-34ad-4c60-8f4c-d41248ee09ac

Testing multiple languages in SharePoint Online and forcing a modern site’s language

An office desk of a designer showing desktop screen, mouse, iphone and other things.

Image by taner ardalı at Unsplash

More often than not I encounter the following scenario (and I suspect this is quite common in a lot of European countries): When a company’s tenant was created they chose their locale as the default language. This might not be an issue, until they remember that the official language should be for example English, which differs from the locale.

A good example is a tenant which was created in Norwegian. This often(*) leads to sites and Office 365 Group modern sites to have Norwegian as the default language, while having it in English would be ideal.

This post cover how to test multiple languages, and also how to force one particular language – as you might want to force different languages for different users. And, you cannot really force the language per site, unless for site collections and communications sites when you create them via an API.

(*) depending on how the site was created

Friday, February 2, 2018

Two free SharePoint Framework Extensions for Office 365 Groups

Hands outstretched with a Christmas gift wrapped in holiday wrapping paper
Photo by Ben White at Unsplash

At Puzzlepart we believe that sharing is caring, and it’s pretty core in how we think about code and solutions. We contribute monthly to SharePoint PnP, but the two extensions released here are not really samples on how to use SPFx, but they solve concrete business problems.

We’ll start off with two extensions, and add more extensions and web parts in the time coming forward.

You can find the code at https://github.com/Puzzlepart/spfx-solutions

Enable Teams on an Office 365 Group

If you are working in an environment where the out of the box self-service of Office 365 Groups have been turned off, but you still want to create Teams for O365 Groups via some other provisioning solution – or give users an alternative to create the Team via the Teams client, this is the extensions for you.

Move Everyone to Visitors

By default in a public Office 365 Group every employee in your organization will have write access to the groups site. I believe you should be an explicit member of a group in order to produce content in it, so it makes more sense for a public group for everyone to have read-only access instead.

This extension sits silently on the group site, and when a group owner visits the site it checks that non-members have read-only and not contribute access. If the Everyone group somehow has been given contribute access, it’s moved back.

Thursday, February 1, 2018

Optimize loading of run-once Application Customizers in SharePoint Framework for Office 365 Groups


Photo by Lex Sirikiat at Unsplash.

When automating Groups provisioning and configurations some configurations cannot be achieved using app-only tokens, but have to be performed by a group owner.

Examples of this are setting the group logo or enabling Microsoft Teams for a group. This is where SharePoint Framework application customizers come in handy.

The idea is to run a piece of JavaScript once an owner enters the group site for the first time, and then remove the application customizer once run, as it’s not needed anymore.

I wrote a sample customizer for this which you can find at the PnP sample repository on GitHub.

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

SharePoint_Page_long_2.png

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.

Employeedirectory_contributors.png

Thursday, January 25, 2018

Automating Office 365 Groups Lifecycle/Expiration management

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

image


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
    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.