Thursday, September 27, 2018

Workaround for removing a deep folder structure in SharePoint

Deep water signage

I had a client which were not able to delete a deep folder structure from SharePoint which I’m guessing was synced in via OneDrive.

The error they got when trying to delete anything in the structure was “Error Code: 6404” – not a very descriptive error.

image

I tried all sorts of API’s, but having worked with SharePoint and Windows for a while I figured this had to do with a total path being too long, and I was correct.

In the end I renamed every single folder to “a”, just one character, and then the total path length was short enough for SharePoint Online, and the structure deleted nicely.

Photo by Rosie Kerr on Unsplash

Example of wrapper to ease usage of Graph calls in SPFx

silhouette of trees and purple lightning

Waldek Mastykarz wrote a good post about not passing the web part context all around your React components, which is good advice. And as Waldek pointed out after reviewing my code I pass the full context and not just the GraphClient. So ideally, passing just what you need is better, but I’m lazy at times :) And it gives you the reader an opportunity to improve my code :)

I tend to create static helper classes, and here’s one approach to ease calling Graph API’s throughout your solution.

The wrapper class is quite simple, and I’ve created helper methods for GET, POST, PATCH, DELETE.

To use this you would first initialize the class in your main web part code.

public async render(): Promise<void> {
   await MSGraph.Init(this.context);
   ...
}

and somewhere in your code if you wanted to get Group data for a group you could use something like this:

import { MSGraph } from '../services/MSGraph';

...

let groupId = this.props.context.pageContext.legacyPageContext.groupId;
let graphUrl = `/groups/${groupId}`;
let group = await MSGraph.Get(graphUrl);

Photo by Jeremy Thomas at Unsplash

Monday, September 10, 2018

An approach to search for a URL within a page or document in SharePoint

image

The Search Explained Yammer network is a great place to ask the weird and quirky search questions. Unfortunately it’s not indexed by Google, so answers there will not benefit everyone – which is why I’m writing this post.

A couple of days ago someone posted a question if it was possible to find pages in SharePoint which contain a specific link. The need was to identify broken links. Use-case can be if you rename a file, and want to find all pages linking to that file before renaming – to make sure they still point correctly.

This post will show you one approach which works, and if you have a better suggestion, please let me know.

Question is; how can you go about finding a page with the link https://contoso.sharepoint.com/sites/collection/site/library/document.docx as part of the content?

Monday, September 3, 2018

Puzzlepart presents the modern flexible Divider web part

Did you ever think the Divider web part for modern pages was too restrictive? Maybe you wanted to cross that divide with a wider one, maybe you wanted to separate with colors? Don’t worry – now you can!

The sharing minds of Puzzlepart hereby introduce the flexible divider web part which allows you to set both the width and the color!

preview

Get the web part code from the link below, or contact us if you want assistance on a pre-compiled tenant wide distributed web part.

https://github.com/Puzzlepart/spfx-solutions/tree/master/Pzl.Part.Divider