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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Script fails to run in...
Power Automate
Unanswered

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,129 Super User 2025 Season 2 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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard