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 / Script fails to run in...
Power Automate
Suggested Answer

Script fails to run in Excel Online

(1) ShareShare
ReportReport
Posted on by 2
Hello,
 
I have an Excel file that uses Power Query to connect to a Power BI report.  The data is pulled in as three separate tables in the Excel file.  The Power BI report is scheduled to update daily.  I would like to be able to use Power Automate to schedule the Excel file to update daily, as well, so that it will always reflect the most recent data in the Power BI report.

To allow Power Automate to update the connections automatically, I created a Script in the Excel file which simply updates all connections in the workbook.  Here is the script that I use:
 
function main(workbook: ExcelScript.Workbook) {
    workbook.refreshAllDataConnections(); // This refreshes all connections
}
 
When I open the workbook and run the script, the data in the workbook refreshes fine.  However, when I try to run the flow in Power Automate, it says that the script fails to run.  This is the error message that I receive:
 
Action 'Run-script' failed
We were unable to run the script. Please try again.
Office JS error: Line 2: Workbook refreshAllDataConnections: There was an internal error while processing the request.
clientRequestId: f2c84415-32a9-40e8-b129-403af56b4b27
 
When I open the file in a web browser, it seems to run the script without issue, so I'm not sure why it won't work when I try to run the flow.  Does anyone have any suggestions?
 
My file is saved in a Teams group, in case that information is relevant.
Categories:
I have the same question (0)
  • Suggested answer
    Nived_Nambiar Profile Picture
    18,136 Super User 2026 Season 1 on at
    Hi,
     
    If the script has worked by executing from excel- it should have worked when running using Run script action. 
     
    As additional information you have provided, the file is saved in teams group- could you try to move the file to other location, reference the file in run script and try to run the flow again ?
     
    see whether that works ?
     
    Thanks & Regards,
    Nived N 
    LinkedIn: Nived N's LinkedIn
    YouTube: Nived N's YouTube Channel
    Blog: Nived Nambiar's Blogs
     Found my answer helpful? Please consider marking it as the solution!
     Your appreciation keeps me motivated. Thank you!

     

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!

Leaderboard > Power Automate

#1
David_MA Profile Picture

David_MA 251 Super User 2026 Season 1

#2
Haque Profile Picture

Haque 239

#3
Expiscornovus Profile Picture

Expiscornovus 220 Most Valuable Professional

Last 30 days Overall leaderboard