Use MS Lists and Power Automate to copy files to MS Teams

This blog post is a continuation of the work we did in:

Drawing inspiration from a PMO (project management office) team managing multiple projects from a centralized List in mind, we will copy template files to the project team as part of the provisioning process.

Part 1 – Update “Projects” list

I’ve added a new Hyperlink column, called “SharePoint Link” to the “Projects” list.

SharePoint Link
Column nameColumn type
TitleTitle used to store the project name.
DescriptionSingle line of text used to store the project description.
VisibilityChoice with the following options: “Private” and “Public”. Indicates if a team should visible to non-team members.
OwnersPerson or Group with Allow multiple selections enabled.
MembersPerson or Group with Allow multiple selections enabled.
LinkURL used to store the web link to the newly created Teams team.
Private Channel OwnerPerson. Important: do not allow multiple selections. We can only add one owner to the private channel using Graph.
SharePoint LinkHyperlink used to store the SharePoint site associated with the newly created Teams team.
Complete list

Part 2 – Update Flow Get SharePoint URL

I’m updating the Flow created in Use MS Lists and Power Automate to provision Private Channels in Teams to include the steps required to get the underlying SharePoint site URL of the newly created Teams team. My starting point looks like the image below.

Completed Flow.

Add a Azure AD – Get group step and set Group Id to “Team ID” from the previous Get a team step (contained in the Condition action).

Get group

Insert a new HTTP action and set:

  • Method to “GET”
  • URI to https://graph.microsoft.com/v1.0/groups/<Id>/drive where <Id> is from the previous Azure AD – Get group step
  • Authentication to “Active Directory OAuth”
  • Tenant to “variables(‘varConnectInfo’)?[‘varDirectoryID’]”
  • Audience to https://graph.microsoft.com
  • Client ID to “variables(‘varConnectInfo’)?[‘varApplicationID’]”
  • Credential Type to “Secret”
  • Secret to “variables(‘varConnectInfo’)?[‘varSecret’]”

Save and test the Flow. Copy the output from the HTTP step.

Output from the HTTP step

Add a Parse JSON step, set:

  • Content to “Body” from the previous HTTP step
  • Click “Generate from sample” and past in the copied output from the previous HTTP step
Parse JSON step

Insert a new Initialize variable and set Name to “varWebURL”, Type to “String” and Value to following expression:
substring(body('Parse_JSON_-_Get_Group_Drive')?['webUrl'], 0, lastIndexOf(body('Parse_JSON_-_Get_Group_Drive')?['webUrl'], '/'))

Initialize variable

This expression trims the Document Library path from the site URL.

Insert a new SharePoint Update item action and set:

  • Site Address and List Name to your target site and list
  • Id to “ID” from the When an item is created step
  • Title to “Title” from the When an item is created step
  • Visibility Value to “Visibility Value” from the When an item is created step
  • SharePoint Link to the “varWebURL” variable
Update item Projects

At this point in the Flow we create a new Teams team, add a private channel, get the SharePoint URL and save it back to our List. In the next section we will check for the General folder in the Groups default drive. The General folder maps back to the General channel in the team. As I understand it, the default Files tab does not provision until you visit the team. To work around the delayed provisioning we will check for the folder and if it does not exist create it.

Part 3 – Update Flow Copy Files

Insert a new Scope action. This will be our “Try” for a Try-Catch-Finally pattern. Add a SharePoint Get folder metadata using path action and set:

  • Site address to “varWebURL”
  • Folder Path to “/Shared Documents/General”

Insert another Scope action. This will be our “Catch” for the Try-Catch-Finally pattern. Add a SharePoint Create new folder action and set:

  • Site address to the “varWebURL” variable
  • List or Library to “Documents”
  • Folder Path to “/General”

Click the ellipse on the Scope action, select “Configure run after”. Set Scope – Try to “has failed” and click “Done”.

Scope catch
Run after settings

This means that Flow will create the General folder if check for the General folder fails.

Insert another Scope action. This will be our “Finally” for the Try-Catch-Finally pattern. Add a SharePoint Copy folder action and set:

  • Current Site Address to your source site that is hosting the project files
  • Folder to Copy to your source folder that is storing the project files
  • Destination Site Address to “varWebURL”
  • Destination Folder to “/Shared Documents/General”
  • If another folder is already there to “Replace”.

My completed and albeit lengthy, Flow is shown in the image below.

Test by creating a new row in the Projects list.

If all goes well your Flow will execute without errors, a new Teams team (1) with a Private Channel (2) will be created and the project files (3) will copied to the team!

I find it amazing that with a List and Power Automate you can piece together a Teams provisioning solution without too much fuss. I wouldn’t use this solution for provisioning at large scale (think thousands) but I would for small-to-mid scale (think hundreds) use cases where consistency, control and eliminating manual efforts are the goal. I reference a PMO throughout these posts as a source of inspiration but this solution could easily be tailored for uses like committee management or mass departmental team creation.

Thanks for reading.

NY

5 thoughts on “Use MS Lists and Power Automate to copy files to MS Teams

  1. Hi Norm another great and useful blog.
    Keep up the great work!
    Question on Microsoft Lists – could it be used to track department risks?
    In my department a risk can have 3 separate actions to help mitigate the risk. Also each action can have a separate team member owner.
    Risk Action Action owner
    Risk 1 Action A Peter B
    Action B Sam T
    Action C Craig S

    Kind regards
    Amardip

    Like

    1. For sure you can use Lists and Power Automate to track department risks.

      I would have two lists. A List to store the Risk level and owner and another List to store the Department risks. Power Automate would evaluate the risk level, pull the owner, and then execute the correct action.

      What do the risk actions look like?

      NY

      Like

  2. Hi Norm
    So for example the department risk could be “there is a risk project A will not be delivered on time and within agreed budget”.

    The actions to mitigate this risk could be:
    Acton 1 – understand if project deadline can be pushed back.

    Action 2 – clarify if all functional requirements need to be implemented.

    So in this example risk A has 2 actions.
    Hope this helps.
    Amardip

    Like

    1. Hi Amardip,

      Each evaluation (condition) would store the respective actions. Unless I am missing something, this is doable with Lists and Power Automate.

      That sounds like a good future blog post as well!

      NY

      Like

Leave a Reply to Norm Young Cancel reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s