Google App脚本错误:您无权调用getActiveForm? [英] Google App Script Error: You do not have permission to call getActiveForm?
问题描述
我正在创建一个脚本,它从表单获取信息并将其写入日历。当我在脚本编辑器中运行该脚本时,它效果很好,从电子表格中获取信息并创建日历事件。然而,当我填写形式并提交(提交是触发器)时,我得到一个错误,指出我没有权限调用getActiveForm()。我拥有表格和日历。
$ b
代码
函数createEvent(){
var calendarToUse =testing;
变种ssUrlToUse =的 https://docs.google.com/a/bay.k12.fl.us/spreadsheets
/ d / 1ZTDQL9G5U7RqbbKQbAfb3ERqFwpSsC3EOQxdD1zdQwA /编辑#GID = 441997215’ ;
/ * Get Canalnder * /
var calen = CalendarApp.getCalendarsByName(calendarToUse);
var cal = calen [0];
Logger.log(cal.getName());
/ *得到答复信息* /
变种mySS
= SpreadsheetApp.openByUrl(ssUrlToUse).getActiveSheet()
Logger.log(mySS .getName());
var values = mySS.getDataRange()。getValues();
var response = values [values.length-1];
var i = 2;
var desc = response [i];
var loc = response [i + 1];
var start = makeGreatDate(response [i + 2],response [i + 4]);
var end = makeGreatDate(response [i + 3],response [i + 6]);
var title = response [i + 5];
/ *填充日历事件* /
var event = cal.createEvent(title,start,end,{
描述:desc,
位置:loc
});
};
函数makeGreatDate(日期,时间){
var day = new Date(date);
day.setHours(time.getHours());
day.setMinutes(time.getMinutes());
Logger.log(日期为+日);
回报日;
}
同样的问题。我的脚本只是将表单回复和格式转换成电子邮件。类似于OP我不做出 FormApp.getActiveForm单个调用()
在我的脚本的任何地方。
此权限问题在我添加 PropertiesService.getScriptProperties()
调用后立即开始。
虽然不是一个完整的解决方案,我可以通过为 FormApp.getActiveForm()
添加一行来保存,然后保存我的触发器(再次检查权限)。我被要求为脚本确认 Offline Access
权限。
I am creating a script that takes information from a form and writes it to a calendar. When I run the script in the script editor it works great, takes information from the spreadsheet and creates a calendar event. However, when I fill out the forma and submit ( submit is the trigger) I get a error stating I do not have permission to call getActiveForm(). I own both form and calendar. I appreciate any ideas.
Code
function createEvent() {
var calendarToUse = "testing";
var ssUrlToUse ='https://docs.google.com/a/bay.k12.fl.us/spreadsheets
/d/1ZTDQL9G5U7RqbbKQbAfb3ERqFwpSsC3EOQxdD1zdQwA/edit#gid=441997215';
/* Get Canalnder*/
var calen = CalendarApp.getCalendarsByName(calendarToUse);
var cal = calen[0];
Logger.log(cal.getName());
/* get info from responses*/
var mySS
=SpreadsheetApp.openByUrl(ssUrlToUse).getActiveSheet()
Logger.log(mySS.getName());
var values = mySS.getDataRange().getValues();
var response = values[values.length-1];
var i=2;
var desc = response[i];
var loc = response[i+1];
var start = makeGreatDate( response[i+2], response[i+4]);
var end = makeGreatDate(response[i+3],response[i+6]);
var title = response[i+5];
/* populate calendar event*/
var event = cal.createEvent(title, start, end, {
description : desc,
location : loc
});
};
function makeGreatDate(date, time) {
var day = new Date(date);
day.setHours(time.getHours());
day.setMinutes(time.getMinutes());
Logger.log( "The Date is"+ day);
return day;
}
I'm running into the same issue. My script just took the form response and formats into an email. Similar to the OP I do not make a single call to FormApp.getActiveForm()
anywhere in my script.
This permissions issue started immediately after I added a PropertiesService.getScriptProperties()
call.
While not a full fledged solution, I was able to work around this by adding a line for just FormApp.getActiveForm()
, saving, then saving my triggers (to check for permissions again). I was asked to confirm Offline Access
permissions for the script.
I then removed the unneeded line and the form worked fine.
这篇关于Google App脚本错误:您无权调用getActiveForm?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!