简体   繁体   English

语法错误:缺少),但我没有看到。 我的引号似乎也不是问题

[英]Sytax error: Missing ), but I don't see it. My quotation marks don't seem to be the problem either

I've been working on this app script trying to automate data from a Google sheet to create events on Google Calendar.我一直在研究这个应用程序脚本,试图自动化 Google 工作表中的数据以在 Google 日历上创建事件。 I've tried changing the Quotation marks from single to double and back.我尝试将引号从单引号更改为双引号并返回。 I've checked my () over and over.我一遍又一遍地检查我的()。 I cannot see what I've done that gives me the syntax error.我看不到我所做的事情给了我语法错误。 If you can see it, please tell me.如果你能看到,请告诉我。 This is making me nuts.这让我发疯了。

function AutomateCalendarEvent() {
  let sheet = SpreadsheetApp.getActiveSheet();
  let pqCalendar = CalendarApp.getCalendarById("zyxwvutsrqp");  
  let reservation = sheet.getRange("C2:E1105").getValues();
  reservation.splice(0, 1);
  let rows = sheet.getDataRange().getValues();
  rows.forEach(function (row, index)  {
    if (index === 0) return;
    if (row[C3]) return;
    
  pqCalendar.createAllDayEvent("Last Name"C2:C, "Arrival Date"D2:D, "Departure Date"E2:E);
    
   })
}

Take a look at my comments看看我的评论

function AutomateCalendarEvent() {
  let sheet = SpreadsheetApp.getActiveSheet();
  let pqCalendar = CalendarApp.getCalendarById("zyxwvutsrqp");  
  let reservation = sheet.getRange("C2:E1105").getValues();
  reservation.splice(0, 1);
  let rows = sheet.getDataRange().getValues();
  rows.forEach(function (row, index)  {
    if (index === 0) return;
    if (row[C3]) return;//C3 should be an index between 0 and 2
    
  pqCalendar.createAllDayEvent("Last Name"C2:C, "Arrival Date"D2:D, "Departure Date"E2:E);//parameters should be a string followed by two dates
    //this is not the way insert parameters into above command.  Ranges do not return values
   })
}

Assuming your data are as follows假设您的数据如下

在此处输入图像描述

Try (to prevent duplicates, the event ID is here stored in column AI fr instance)尝试(为防止重复,此处事件 ID 存储在 AI fr instance 列中)

function AutomateCalendarEvent() {
  let sheet = SpreadsheetApp.getActiveSheet();
  let swCalendar = CalendarApp.getCalendarById("***********@gmail.com");
  let rows = sheet.getRange(1, 1, sheet.getLastRow(), sheet.getLastColumn()).getValues();
  rows.filter(row => row[2] != '').forEach(function (row, index) {
    if (index === 0) return;
    if (row[34] == '') { // AI
      try {
        sheet.getRange('AI' + (+index + 1)).setValue(swCalendar.createAllDayEvent(row[2], row[3], row[4]).getId())
      } catch (e) { console.log(e) }
    }
  })
}

reference参考

createAllDayEvent(title, startDate, endDate, {options}) createAllDayEvent(title, startDate, endDate, {options})

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 汉堡的小问题,但我看不到。 请帮我找出错误 - Small problem with hamburger, but I don't see it. Help me to find error please JSON语法错误...我没看到 - JSON Syntax Error… I don't see it 我的提示似乎不起作用 - My prompts don't seem to be working 我的代码在第5行有一个问题,说“Missing'()'调用一个构造函数”,我不知道如何调试 - There is a problem in my code on line 5 stating “Missing '()' invoking a constructor” and i don't know how to debug that 为什么我在 Stack Navigator 中看不到任何渲染内容? - Why Don't I See Anything Rendering in My Stack Navigator? 为什么我在JavaScript中看不到字符串的.value属性? - Why don't I see the .value property for my string in javascript? 我没有看到我的图片,只有 alt 属性 - I don't see my picture but only the alt attribute 以科学计数法将数字写入JSON,这样它们就不会在其周围引起引号 - Writing numbers to JSON in scientific notation so that they don't get quotation marks around them 为什么有些js参数需要引号而有些不需要? - why do some js parameters require quotation marks and others don't? 为什么我在客户端看不到错误异常? - Why I don't see error exception on the client?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM