Excel Scripts - refreshAllDataConnections()

jetjet 6 Reputation points

I'm using Excel Online and have a very simple Excel Script that I want to trigger via Power Automate

The script is

function main(workbook: ExcelScript.Workbook) {  
	// Refresh all data connections  

When I trigger this script from Excel Online, nothing will happen.

But, if use the UI to click on the 'Refresh All Connections' button I get the below the prompt


Be careful. The query to get the data might be unsafe so you should only refresh the workbook if you trust its source.
Do you want to refresh the workbook?

I click Yes and then try running my Script again and it works beautifully refreshing the data. But as soon as I reload the page in Chrome, the script won't work until I follow the process above again.
How can I trust the connection or add some code in the script to ignore this message?

The excel file is on my OneDrive for Business and I've tried adding that folder as a trusted folder in Excel Desktop without any luck. The connection is to a PowerBI OLAP if that makes a difference

Office Development
Office Development
Office: A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.Development: The process of researching, productizing, and refining new or existing technologies.
1,977 questions
Excel Management
Excel Management
Excel: A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.Management: The act or process of organizing, handling, directing or controlling something.
1,348 questions
No comments
1 vote

1 answer

Sort by: Most helpful
  1. Max Børglum Stripp 1 Reputation point

    Did you find a solution? @jetjet

    No comments