I have developed an addon composed of :
- an Apps Script bound to a spreadsheet
- an external web UI which calls some Apps Script function thanks the Apps Script API.
Here an example of my code :
1) in my external web UI I do something like :
window.gapi.client.script.scripts.run({
scriptId: 'myscripID',
resource: {
function: addWorksheet,
parameters: [
'worksheetName'
],
devMode: false
}
....
2) And the in my app Script I have the function :
function addWorksheet(worksheetName) {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var newSheet = ss.insertSheet(0);
ss.setActiveSheet(ss.getSheetByName(newSheet.getName()));
newSheet.setName(worksheetName);
return(newSheet.getName());
}
Problem description : The problem is when I test my add-on from 'Run->Test as add-on ..." menu, on the container-bound Scripts, it's working well. => The new sheet is well created.
But if I test it on a another Google Sheets, the new sheet is created in the container-boundScripts but not in the active Google Sheets.
I have also remarked if I install the addon from another account than this used to create the container-bound Scripts, the following error is raised :
@type: "type.googleapis.com/google.apps.script.v1.ExecutionError" errorMessage: "You do not have permission to access the requested document." errorType: "ScriptError"
Help will be greatly appreciated !