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.

 

When an item is created or modified trigger

 

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.

Get the Site Url and list name from the When an item is created or modified trigger

Then within my Get items action I use

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

and this is where you can see a small problem:

Get items action using the compose output

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.

Get items using a variable instead of compose

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.

 

Avatar for Pieter Veenstra

By Pieter Veenstra

Business Applications Microsoft MVP working as a Principal Architect at HybrIT Services Ltd. You can contact me using contact@sharepains.com

16 thoughts on “Creating generic flows in Microsoft Flow using the SharePoint connector”
  1. 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?

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

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

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

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

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

      1. 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”
        }

  5. When I set up variables for sites and SharePoint lists, the following actions like Update Item or Create Item will not have all fields showing up correctly. Does this happen to your list?

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from SharePains by Microsoft MVP Pieter Veenstra

Subscribe now to keep reading and get access to the full archive.

Continue Reading