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 / Flow calling an Office...
Power Automate
Answered

Flow calling an Office Script to refresh a Power Query

(1) ShareShare
ReportReport
Posted on by 79
I'm working on some basic reports that I'd like to completely automate within the MS Stack.
 
I have a number of flows already set up that grab data reports received via email and uploads them into a dedicated SharePoint site.
 
From there, I have various excel working "reporting templates" of various complexity that also live in a SharePoint site. The automation I'm focused on for now is a simple report that is just a straight query refresh and the output table is the actual report.
 
The flow I'm working on would:
 
  1. Trigger at a scheduled time
  2. Call an office script that is supposed to refresh the query and place a time stamp on a sheet for the last refresh
  3. Delay to allow time for the query to refresh
  4. Get the file metadata
  5. Delay again to ensure the correct version has been synced with SharePoint
  6. Condition based on the data output from the table
    1. If there is no data in the table, send an email saying "nothings here"
    2. If there is data in the table, select specific columns, convert to an HTML table with certain formatting, and send an email saying "here is the data"
  7. Finally, update a SharePoint list with the date of the last successful flow run
The flow works, but my issue is actually with the office script being used. The script is:
 
function main(workbook: ExcelScript.Workbook) {
workbook.refreshAllDataConnections();
let sheet = workbook.getWorksheets()[0];
sheet.getRange("A1").setValue("Refreshing...");
sheet.getRange("A1").setValue(new Date().toISOString());
}
 
The timestamp of when the script is triggered populates, and the action in the flow shows as successful, but the query output table is wrong. When I go in and manually refresh the query the refresh works exactly as expected. I'll then delete a row or two and allow the flow to trigger, and the output table clearly doesn't refresh as the deleted rows are still missing but the query refresh should restore them.
 
Curious if anyone has an idea of how to effectively trigger a power query refresh through an office script or other means via power automate.
 
Appreciate any assistance. Thanks!
I have the same question (0)
  • Verified answer
    Expiscornovus Profile Picture
    33,874 Most Valuable Professional on at
     
    Afaik refresh is still not fully supported in Office Scripts within Power Automate. So, you might be running into that limitation.
     
    For reference see this documentation:
     
    Wouldn't you be able to move it to a semantic model instead in Fabric/Power BI workspace and move the data refresh part to the workspace?
     
     
    Happy to help out 😁

    I share more #PowerAutomate and #SharePointOnline content on my Blog, LinkedIn, Bluesky profile or Youtube Channel
  • Verified answer
    FlowingBuckle Profile Picture
    79 on at
    Hey @Expiscornovus - I agree that is likely the limitation I am running into. The script does run successfully, but when triggered by the flow it still "runs successfully" with the caveat that it actually hasn't refreshed as proven by the timestamp updating but the output table not truly refreshing.
     
    Currently my organization doesn't have an active BI license, and I'm not personally familiar with Fabric. I'm trying to accomplish this task using the applications and tools I already have access to. I could likely convince them to get a license for BI, and I do have some experience with the application as well, but the effort of doing so to fully automate a process that really only takes me ~2-3 minutes of manual effort is arguably profuse.
     
    This is more of a "let me see if I can do this" type of effort as opposed to something truly necessary. I appreciate the input though! I'm sure there's some way this can be done with the tools I have available, just gotta keep digging.
  • Expiscornovus Profile Picture
    33,874 Most Valuable Professional on at
    Hi, 
     
    Good to know that context.
     
    In that have you tried an RPA approach? In other words try and click the data refresh button from a desktop flow (that might even be possible in an unattended scenario). Still Power Automate, but different type of flow. 
     
     
    Happy to help out 😁

    I share more #PowerAutomate and #SharePointOnline content on my Blog, LinkedIn, Bluesky profile or Youtube Channel
  • FlowingBuckle Profile Picture
    79 on at
    I think my next, and potentially last viable, attempt will be to set the query's properties to refresh upon open and then configure PA Desktop to open the file, wait ~2 minutes, and then close the file.
     
    This would require my computer to be on in order to work, where my original intent was for this to all be done via the cloud and not require my machine to be on.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Vish WR Profile Picture

Vish WR 959

#2
Valantis Profile Picture

Valantis 872

#3
Haque Profile Picture

Haque 589

Last 30 days Overall leaderboard