Excel Scripts - refreshAllDataConnections()

jetjet 26 Reputation points
2021-11-04T11:32:46.107+00:00

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  
	workbook.refreshAllDataConnections();  
}  

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

146561-image.png

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.
3,480 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,639 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Max Børglum Stripp 1 Reputation point
    2022-06-08T12:58:31.65+00:00

    Did you find a solution? @jetjet