John Liu .NET

View Original

Flow For-Selected-Item trigger and SharePoint Site Pages, in a detective story

This is a long blog post, there are two parts:

  1. How do you make a SharePoint For Selected Item in Flow, and have it appear on the SharePoint Site Pages library
  2. Explain the magic rituals you just did to figure all this out

The Problem

Paul Matthews reached out and asked if it's possible to create a "For a selected item" Flow against Site Pages.  

I was able to reproduce what he's asking fairly quickly.

 

The Solution

May be you just want the solution.  The solution is that you need to use the "list guid" as the custom value for the SharePoint For Selected Item trigger, not the List Title.

 

The Detective Novella

Ah you are still here.  OK, buckle yourself in, we are going another Flow adventure.

First, when realizing that the For a Selected Item doesn't appear in Site Pages, I immediately call the SharePoint REST method SyncFlowInstances()

I do this of course, with another Flow.

This returns empty array for SynchronizationData.  This means:

SharePoint Site Pages don't know anything about my Flow.  It thinks there's no Flow connected to it.

Create an Out of Box Request sign-off Flow on Site Pages

SyncFlowInstances returns this Request sign-off Flow

So we know Flow can run on the Site Pages library, just not "Our" Flow.

I want to compare the JSON definition differences.

The Request sign-off Flow is owned by the SharePoint list, not by me.  So I can't read its definitions (I can't even see it in my list of Flows view)

So I created a Flow to assign the Request sign-off Flow to me.

This is necessary to add myself as a Owner to this Flow.

Now I open these two Flows with Flow Studio.

I can see both the working Flow (on the left) and the not-working Flow (on the right)

https://flow-studio.azurewebsites.net/

Checking the trigger JSON, I find that the Flow on the right (not working) has "Site Pages" as the name, but on the left (working) has a GUID as its name.

Summary

We explained the problem - it is the Site Pages not appearing as a choice - it's not a List nor a base Document Library.  Typing the name "Site Pages" doesn't work.

The solution is to use the list Guid.

And the debugging steps takes us to SyncFlowInstances, Modify FLow as Admin to assign a new template flow back to me as the owner, and finally using Flow Studio to change the existing "Site Pages" to the list guid.