I have a Google Spreadsheet with which I've created a Google Form. The spreadsheet has two sheets: one with form responses, and one with configuration data. Attached to the spreadsheet is a form-response-triggered Apps Script script that uses the configuration data to make an API call. This script runs exactly as I desire.
I have written spreadsheet-change-triggered script which attempts to update choices for one of the form's questions. However, using FormApp.openById or FormApp.openByUrl fails with "You do not have permission to call ...".
Is there some way to give the spreadsheet-change-triggered script permissions to the form?
Or is there a better setup for what I need here: keep information sync'd between a form and the script making api calls based on the form responses?
Code:
function onEdit(e) {
var activeSpreadsheet = SpreadsheetApp.getActiveSpreadsheet();
// Do some work to get the configuration data. This works fine.
// Now try to get access to the form to update it
var responseSheet = activeSpreadsheet.getSheetByName('Form Responses');
// var form = FormApp.getActiveForm(); // returns null
var form = FormApp.openByUrl(responseSheet.getFormUrl());
...
}
The final line fails with:
Execution failed: You do not have permission to call openByUrl