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.
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 ?
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.