我在 Google 文档(不是工作表)中有一个表格。第一列包含一个 ID 号,该 ID 号与提交数据的 Google 表格中的相对 ID 相匹配。
//This is what the table looks like
//[id][name][favourite cheese]
//[3 ][bob ][chedder]
//[4 ][jane][old english]
Run Code Online (Sandbox Code Playgroud)
我需要
这是我当前的代码:
// Grab the Table
var body = DocumentApp.openById('theId').getBody(),
searchElement = body.findElement(DocumentApp.ElementType.TABLE),
element = searchElement.getElement(),
table = element.asTable();
Run Code Online (Sandbox Code Playgroud)
这部分代码用于获取表格,因为您无法在 Google 文档中命名表格。
我很惊讶我找不到更多信息。我正在尽最大努力利用文档,并感觉我将使用“For Loop”来搜索每一行,但我需要 .getElement(row) 来循环吗?我可以使用 .findText() 还是会显示包含文本的表的每个部分。也许我可以以某种方式在每行的第一列中循环 .getElement(row) 和 .findText() ?
我知道循环是一个相当基本的 Javascript 概念,只是 Google 文档的处理方式让我感到困惑。
提交 Google 表单后,我想触发一个“触发器”,在 Google 工作区中创建一个“空间”。
我在 GAS(Google Apps 脚本)中找不到任何记录 Google Workspaces 的文档。
来源: https: //developers.google.com/apps-script/overview
由于产品的命名,当尝试在最近重新命名的谷歌“工作空间”中创建“空间”时,谷歌搜索会感到困惑。
目前不支持 Apps 脚本和“Spaces”吗?
如果有,您能否链接文档。也许它在文档中以旧名称列出?
javascript google-apps-script google-workspace google-workspace-add-ons
问题
.findIndex() 正在崩溃。我向它提供了一个字符串,但它说“这不是一个函数”
目标/背景
自动回复房产查询
函数执行以下操作:
扫描收件箱以识别询问。
分解电子邮件,将数据存储在变量中。
扫描包含我们所有待售房屋信息的电子表格。将电子邮件中的媒体资源 ID 与电子表格进行匹配以查找匹配项。
使用电子表格中存储的与该属性匹配的数据回复电子邮件。
我要去哪里
我能够识别该电子邮件。然后我就可以扫描电子邮件并提取相关信息。
代码
function autoReply() {
var queryInbox = "is:unread from:(example@gmail.com) to:(example@gmail.com) Example Text:"; // Email Identification
var locatedEmail = GmailApp.search(queryInbox); // Search Inbox for Identification
locatedEmail.forEach(thread => {
var messages = thread.getMessages();
if (messages.length === 1) {
// BREAKING DOWN THE EMAIL
var msgBody = messages[0].getPlainBody();
var identityNumber = msgBody.split("\n")[1].replace('Property ID: ','');
// SPREADSHEET
var SS = SpreadsheetApp.openById('exampleId').getSheetByName("Sheet1");
var column = 1; // column Index
var columnValues …Run Code Online (Sandbox Code Playgroud)