my first post so apologies for any wrong links and format.
I found a very useful piece of script in the link below, and specifically in the code text. It works great for single import ranges, but I need to have multiple sheets linked in the Const donorID and in the Const URL. Is this possible?
Is sO, please assist with a sample modified script.
How to allow access for importrange function via apps script?
function addImportrangePermission() {
// id of the spreadsheet to add permission to import
const ssId = SpreadsheetApp.getActiveSpreadsheet().getId();
// donor or source spreadsheet id, you should get it somewhere
const donorId = '1GrELZHlEKu_QbBVqv...';
// adding permission by fetching this url
const url = `https://docs.google.com/spreadsheets/d/${ssId}/externaldata/addimportrangepermissions?donorDocId=${donorId}`;
const token = ScriptApp.getOAuthToken();
const params = {
method: 'post',
headers: {
Authorization: 'Bearer ' + token,
},
muteHttpExceptions: true
};
UrlFetchApp.fetch(url, params);
}