Creating generic flows in Microsoft Flow using the SharePoint connector

One of the differences between SharePoint Designer workflows and Microsoft Flow is the way you can have multiple copies of the same flow for multiple lists and or libraries. Where in SharePoint Designer you would be able to refer to the current list. Flow does not offer this option. Therefore when you create copies of a flow you will find that you are updating the site url and the list name in many different places.

In the past I tried to make sure that my SharePoint actions would use dynamic content or variables however this was never supported as Flow wasn’t able to validate list columns during design time.

Today I tried this again and I found that things worked.

In my flow I started with a When an item is created or modified.

 

 

Then I set two variables a SiteUrl and a ListName. I used the Compose actions rather than the variables connector to do this for performance reasons. However you could consider using variables as that will make your flows more readable. We will see this shortly.

Then within my Get items action I use

outputs('ListName')
outputs('SiteUrl')

and this is where you can see a small problem:

If you get it wrong you will rely on the hover over tool tips to find out what you did wrong. When you use a variable instead of a Compose action you will notice the difference.

Now when you create multiple copies of the same flow you can simply update the variables and potentially the trigger and you can copy flows from one list to another within seconds. It woud still be nice if you could get the list name and the site url out of the trigger but at least this is a good start towards creating generic flows.

 

Share
Pieter Veenstra

Business Applications and Office Apps & Services Microsoft MVP working as a Microsoft Productivity Principal Consultant at HybrIT Services. You can contact me using contact@veenstra.me.uk.

View Comments

  • In this example you are creating variables to be used in subsequent actions. Is it still the case that the trigger is going to be fixed? Meaning it's value must be changed during each copy? Have you found a way to make the trigger entries dynamic?

    • Hi Adam, the only option I could possibly see work is by using the options in the flow management connector and replace on URL with another on the way. Manual copying and a single update was easier to implement so far.

  • Hi, how did you get the listname and url from the trigger? It is not listed in the output? Did you ‘parse’ the item link or use another expression? Thank you.

    • If you use any of the file or item triggers then you can create this from the list item url.

  • Hi, I’m just beginning to work with sharepoint. How can I get the site url and listname from the sharepoint trigger action? It is not in one of the provided outputs? Thank you.

    • HI Marissa,

      The follwoig expression will do the job:

      concat(split(triggerBody()?['{Link}'],'sharepoint.com')[0], 'sharepoint.com')

  • until you published what were input parameters in both Compose actions, this post is useless

    • Hi Jonm

      The two compose actions get the properties from the trigger.

      The SiteUrl is taken from the SiteUrl property.
      The ListName comes from the ListName property.

      You can select these from the Dynamic contents given by the trigger.

  • Hi Pieter, any chance this has changed recently and the “/Lists/” path is lo longer part of the trigger link? the link I’m getting contains “/_layouts/15/listform.aspx?…” which then redirect to the DispForm containing the “Lists” path.
    Is it safe to split based on “/_layouts/” in order to get the site URL?

      • This is most definitely a (custom) list, here's the output I'm getting for the trigger link:

        "{Link}": "https://****.sharepoint.com/sites/*****/_layouts/15/listform.aspx?PageType=4&ListId=3d8fd8d7-44a5-46d0-bfd7-5713e168e42b&ID=87&ContentTypeID=0x0100FFDEEE6FAB678341BC6374F4D159BD94",
        "{Name}": "10702355",
        "{FilenameWithExtension}": "10702355",
        "{Path}": "Lists/OTP Approvals/",
        "{FullPath}": "Lists/OTP Approvals/87_.000",
        "{HasAttachments}": false,
        "{VersionNumber}": "1.0"
        }

Recent Posts

Filter Query in SharePoint Get Items in Power Automate

Have you tried the experimental version of Filter query in the SharePoint Get Items action…

2 days ago

3 Ways to add a column to an array in Power Automate

When you have an array in Power Automate and you would like to add a…

6 days ago

Patch any field type in a SharePoint list item using Power Apps

In Power Apps the Patch function is very important when you work with data. In…

1 week ago

Call flows from a model driven app

Wouldn't it be great if you could call flows from a model driven app? Well…

2 weeks ago

Variables or Compose? Consider neither in Power Automate

The question is Variables or Compose actions in Power Automate? Variables Sometimes you need a…

2 weeks ago

Your 1st lesson in Power Apps, in a few easy steps!

1st lessons can be so important when you want to get started with Power apps.…

4 weeks ago
%%footer%%