web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / PA looping through Sha...
Power Automate
Answered

PA looping through Sharepoint List with links to Excel documents on different sharepoint sites

(1) ShareShare
ReportReport
Posted on by 14
Hi, I am struggling with the following (even using Claude 😅). I have a list with the copied links to five files (which are on different sharepoint sites). I want to loop through these copied links and run an office script in these files and after running that script get the output of a specific table.
 
I am not getting my around how to populate the three fields in the step Run Script (location, document library and file) on basis of that copied link. Or perhaps there might be a simpler way to achieve this.
 
Hopefully someone can push me in the right direction. Many thanks in advance.
 
Regards, 
 
Michiel
PA flow.jpg
I have the same question (0)
  • chiaraalina Profile Picture
    2,425 Super User 2026 Season 1 on at
    Hi
     
    Why do you have only the link in the SharePoint List?

    You cannot dynamically populate the Location, Document Library, and File fields in the "Run script" action based on a SharePoint file URL stored in a list.
     
     
    Instead of storing just the file URL, store three separate columns:
     
    1. Site Address Column
    Store the SharePoint site URL (e.g., https://tenant.sharepoint.com/sites/Finance)
     
    2. Library Name Column
    Store the document library name (e.g., "Shared Documents")
     
    3. File Path Column
    Store the relative file path within the library (e.g., /Reports/Q1-2026.xlsx)
     
    Hope it helps!
     
  • Suggested answer
    11manish Profile Picture
    3,333 on at
    The challenge is that the Excel Online (Business) → Run script action does not natively accept a SharePoint sharing URL. It expects three separate pieces of
     
    information:
    • Location
    • Document Library
    • File
    When your files are spread across multiple SharePoint sites, a copied link alone is usually not enough for the action to automatically resolve these values.
     
    If you control the source list, do not store copied sharing links. Instead, store:
    • Site Address
    • Document Library
    • File Path
    as separate columns. Then use those values directly in the Run Script action. This is the most maintainable and reliable approach, especially when the files are spread
     
    across multiple SharePoint sites. If you already have only sharing links, you'll likely need an intermediate step (SharePoint or Graph) to resolve each URL into the
     
    actual file path before running the Office Script.
  • MS-16121021-0 Profile Picture
    14 on at
    Many thanks, but @chiaraalina and @11manish how does the notation of the three components need to be in those columns? Just like you wrote it down or does it need to be Sharepoint style so it is one connected string with spaces with % or does it need to be with drive ID's? 
  • Suggested answer
    Valantis Profile Picture
    6,735 on at
     
    For the Run Script action, the three fields expect these exact formats:
     
    Site Address: the full SharePoint site URL https://yourtenant.sharepoint.com/sites/YourSiteName
     
    Document Library: just the display name of the library, not encoded
    Shared Documents
    (or whatever your library is called, e.g. Documents, Reports etc.)
     
    File: the full path to the file starting from the root of the library
    /Shared Documents/FolderName/YourFile.xlsx
     
    No drive IDs needed, no URL encoding with % characters. Plain readable text in all three fields.
     
    If you switch your SharePoint list to store these three values separately in plain text columns, you can map them directly into the Run Script action using the dynamic content from your Get items loop.
     
    One tip: for the File field, include the library name at the start of the path (e.g. /Shared Documents/...) as some tenants require this even though you've already specified the library separately.
     

     

    Best regards,

    Valantis

     

    ✅ If this helped solve your issue, please Accept as Solution so others can find it quickly.

    ❤️ If it didn’t fully solve it but was still useful, please click “Yes” on “Was this reply helpful?” or leave a Like :).

    🏷️ For follow-ups  @Valantis.

    📝 https://valantisond365.com/

    💼 LinkedIn

    ▶️ YouTube

     
     
  • Suggested answer
    chiaraalina Profile Picture
    2,425 Super User 2026 Season 1 on at
     

    I would use the Site URL, the DriveId for the document library, and then the path to the file. That is usually the easiest approach. Using the Display Name doesn't work for me.

    For example:

    Site:

    https://tenant.sharepoint.com/teams/HR

    Document Library:

    b!4heL6G-TLEy_YXUdT9xFGdz3dW......

    File:

    /Book.xlsx

    or, if the workbook is in a folder:

    /Reports/Book.xlsx
     

    You can find the DriveId by first selecting the document manually in the Run script action, then opening Peek code/Code view and copying the resolved drive value.

    After that, you can save the DriveId in a SharePoint column and test your flow.

     

    Hope this helps!

     
     
  • MS-16121021-0 Profile Picture
    14 on at
    Thanks for your contributions (all of course) @chiaraalina only thing is that we constantly have multiple files floating on different sharepoint sites (coming up new ones each quater) and then each time I need to get such a drive id. We will give it a try with the written plain text and if that does not work we need to work around that.
  • Suggested answer
    chiaraalina Profile Picture
    2,425 Super User 2026 Season 1 on at
     
    Sure, try it with the display name only.
     
    If it does not work and you need the Drive Id add a step before the Run Script: Send an HTTP request to SharePoint
     
    In the Site Address add the Site variable and in the Uri _api/v2.0/drives?$filter=name eq '<Display Name of your Document Library>'
     
     
     
    In the Run Script use body('Send_an_HTTP_request_to_SharePoint')?['value'][0]?['id'] in the Document Library field.
     
    This is more dynamically.
     
    Let me know if it worked!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Valantis Profile Picture

Valantis 377

#2
11manish Profile Picture

11manish 279

#3
David_MA Profile Picture

David_MA 234 Super User 2026 Season 1

Last 30 days Overall leaderboard