knowledgecenter-breadcrum

Knowledge Center

08 Sep, 2026

How to Dynamically Retrieve SharePoint Drive IDs and List GUIDs for Power Automate

Posted on 08 Sep, 2026 by Bharathi Siripuram, Posted in SharePoint Power Apps Dynamics 365

Blogs

Introduction

Many times, we come across scenarios where we need to populate a Word template in Dynamics 365 using Power Automate — connecting to Word Online (Business), and directly selecting a SharePoint site, document library, and file inside the action. This works fine... as long as everything stays fixed. One tenant, one site, one library — all manually selected, once.

But stop and think — what if the site changes? What if the drive or list where the template lives gets renamed, moved, or replaced? What if the same flow now needs to run in a different environment altogether — Test, Prod, or a different client's tenant?

Suddenly, manual selection isn't just inconvenient — it's a blocker. Someone has to reopen the flow, delete and reselect the site and library by hand, republish, and hope nothing else breaks along the way.

So what needs to be done instead? The answer is simpler than it sounds: a single dynamic URL — swap only the tenant and site name — returns every Drive ID and List GUID you need. No manual clicking, no developer required to repoint the flow every time something changes.

Pre-requisites

  1. Access to the SharePoint site (signed in via browser)
  2. The tenant name and site name
  3. A Dataverse environment (for storing the values as Environment Variables)

Step-by-Step Guide

Step 1: The Manual Way (and Why it is not scalable)

  • Open the flow → manually select the SharePoint site and library.
  • Save → use Peek Code to find the Drive ID / List GUID.
  • Works once, but breaks the moment the client moves environments — a developer has to redo it every time.

Step 2: Dynamically Get the Site ID and Web ID

  • Replace {tenant} and {site-name}, then paste into a browser:
    • https://{tenant}.sharepoint.com/sites/{site-name}/_api/site/id
    • https://{tenant}.sharepoint.com/sites/{site-name}/_api/web/id 

Step 3: Get Every List GUID and Drive ID on the Site (One Call)

  • Replace {tenant} and {site-name} and search for the required document library 
  • Replace {tenant},{site-name} and {list-name}, then paste into a browser:
    • https://{tenant}.sharepoint.com/sites/{site-name}/_api/web/lists/GetByTitle('{list-name}')?$select=title,id

This returns every document library on the site at once — Title, GUID, and folder path together.

Step 4: Store the Values as Environment Variables — Not a Custom Configuration Table

  • A generic "System Configuration" table (key/value columns) has a dynamic schema, so Power Automate can't bind it directly to an action field.
  • You'd need an extra "Get configuration" step, parse the value as text, then paste it into an expression — losing the simple dynamic-content-picker experience.
  • Environment Variables show up in the flow designer as proper dynamic content, with a defined type, no parsing needed.
  • Moving environments (Dev → UAT→ Prod, or into a client's own tenant) just means updating the variable's value — the flow itself never changes.
  • A client can update this themselves after import, without a developer touching the flow.

 

Common Mistakes

      no Hardcoding the Drive ID or List GUID directly inside flow actions instead of referencing an Environment Variable.

      noStoring SharePoint IDs in a generic configuration table, then parsing them out with extra steps.

     no Assuming the same List GUID works across environments — every site and tenant generates its own IDs — don't reuse one across environments.

Conclusion

One dynamic URL — tenant and site name swapped — replaces manual clicking and code-peeking every time an environment changes. Paired with Environment Variables instead of a custom configuration table, it gives clients a simple, self-service way to repoint a solution at a new site, with no developer required.

Hope you found this helpful!

 

Comment

This is a Required Field

Loading

Recent Updates

Blogs
11 Aug, 2026

How to Remove an Unmanaged Layer from a Dataverse Email Template

Overview Email Templates in Microsoft Dataverse make it easy to reuse email content such as subject lines, message bodies, and…

READ MORE
How to Populate Dynamic Content Using Repeating Controls in a Word Document
Blogs
20 Jul, 2026

How to Populate Dynamic Content Using Repeating Controls in a Word Document

Introduction: Organizations frequently generate documents like invoices, certificates, quotations, transcripts, inspection reports etc. While single-value fields such as Name, Email,…

READ MORE
Blogs
15 Jul, 2026

Recovering a Deleted Option Set(Choice) Value in Dynamics 365 Using Web API

The Problem Recently, we faced an interesting issue while working with the Status Reason (statuscode) field on the Contact table.…

READ MORE