1
votes

I have a spreadsheet with users, from which I automatically create a new spreadsheet (from a template in my drive) when a new user is created.

I then grant the new user permission to look at the spreadsheet and sent it to him via email.

Here's the question:

In the template I have a field that references another spreadsheet via Importrange("spreadsheeturl"). Now everytime a new spreadsheet is created I need to open the sheet with my account and click on "Allow access" in any of the fields that reference the spreadsheet.

screenshot

Is there anyway to that from my code?

1

1 Answers

0
votes

Good question- I honestly couldn't say. But if the point is just to port data from an existing spreadsheet into this new one, you could use code to replace the importrange.

Something like

var ss = SpreadsheetApp.getActiveSpreadsheet(),
data = openById("string-id"),
value = data.getRange(range).getValue();
ss.getSheetByName("sheet-name").getRange(range).setValue(value);

Hope this helps!