Google Script: TypeError: Cannot call method "createEve
Google Script: TypeError: Cannot call method "createEvent" of null
这是我的第一个谷歌脚本,它不工作。当我开始这个脚本在脚本编辑器中测试它时,我得到的错误是站在标题"…var event = cal.createEvent(title, start, end,{…). 你能给我点小费吗?
下面的代码可以吗?
var calendarId = "xyz@group.calendar.google.com";
//Column containg the Start Date/Time for the event
var startDtId = 4;
//Column containg the End Date/Time for the event
var endDtId = 5;
//Column containg the First Part of the Title for the event (In this case, Name)
var titleId = 2;
//Column containg the Comments for the event
var descId = 3;
//Column containg the Time Stamp for the event (This will always be 1)
var formTimeStampId = 1;
//Column containg the Location
var locId = 6;
//Column containg more Informations
var infosId = 7;
function getLatestAndSubmitToCalendar() {
//Allow access to the Spreadsheet
var sheet = SpreadsheetApp.getActiveSheet();
var rows = sheet.getDataRange();
var numRows = rows.getNumRows();
var values = rows.getValues();
var lr = rows.getLastRow();
//Removed setting of Hour and Minute for the Start and End times as these are set in our form
var startDt = sheet.getRange(lr, startDtId, 1, 1).getValue();
var endDt = sheet.getRange(lr, endDtId, 1, 1).getValue();
//Setting the Comments as the description, and addining in the Time stamp and Submision info
var desc = "" + sheet.getRange(lr, descId, 1, 1).getValue() + "n" + subOn;
//Create the Title using the Name and tType of Absence
var title = sheet.getRange(lr, titleId, 1, 1).getValue() + " – " + sheet.getRange(lr, titleId2, 1, 1).getValue();
//Setting the Location
var loca = sheet.getRange(lr, locId, 1, 1).getValue();
//Setting more Information
var infos = sheet.getRange(lr, infosId, 1, 1).getValue();
//Run the Crete event Function
createEvent(calendarId, title, startDt, endDt, desc, loca, infos);
};
function createEvent(calendarId, title, startDt, endDt, desc, loca, infos) {
var cal = CalendarApp.getCalendarById(calendarId);
var start = new Date(startDt);
var end = new Date(endDt);
var loc = loca;
var event = cal.createEvent(title, start, end, {
description: desc,
location: loc
});
};
我在下面的线程中阅读了答案,但我的日历id绝对是正确的。因此,我在这个新帖子里问你。谷歌脚本谷歌日历类型错误:无法调用createevent方法空
这意味着你的cal对象是空的,所以你的CalendarApp.getCalendarByID(calendarID)
行有问题
相关文章:
- 铬:“;未捕获的语法错误:意外的标记:"
- 可以设置“;文件名"发生错误时显示的内联脚本标记的
- JS表单提交"无法使用Chrome数据保护程序加载此页面.尝试重新加载页面.调试信息:POST CISmtuK
- 检测电话窃听,即:<a href="电话:xxx">在UIWebview上
- 使用“+="操作人员
- //而不是在src=“”上使用http://"属性
- "未捕获的语法错误:意外的标记}"
- 可以<脚本类型=“;text/javascript”>window.location=“/"</
- "实例范围”;TypeScript类的getter/setter
- Javascript复选框函数:;缺少:在属性id之后"
- "“;变量未引用正确的对象
- "日期“;AJAX请求返回的类型值未定义
- 得到"TypeError:无法读取属性'filename'未定义的“;调用“npm start
- Soundcloud api"未捕获的类型错误:无法读取属性'uri'“未定义”;
- "工具提示"jQuery插件坏了
- "锻造;React中的表达式
- 图像可以从源<img src=""/>.TEXT可以在没有javascript的情况下从外部
- 如何提取“;href"最近列表项中的属性值
- CKEditor如何允许href="javascript:void(0)"在小部件中
- document.applet.method在Mounatin Lion上抛出safari 6+JDK7异常