0

我观看了一个 youtube 视频,标题为“Google Apps EDU Fireside Chat Hangout: An Introduction to Apps Script”,其中 Eric Koleda 展示了如何从 gmail 进行“批准”。

我已经复制了代码,除了 doGet 函数(见下文)外,一切正常。该功能假设在电子表格的审批列中写“是”,然后呈现一个写有“公告已获批准”的网页。

任何帮助表示赞赏。请参阅下面的代码。

function onFormSubmit(event) {
  var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = spreadsheet.getSheetByName('Announcements');
  var title = event.namedValues['Title'];
  var description = event.namedValues['Description'];
  var url = 'https://script.google.com/a/macros/domain.com/s/AKfycbxT0T7bdcZ0NGmRHoZuo5onrPol9bMNDK8W4fYWol5gS09xKXk/exec';
  url += '&spreadsheetId=' + spreadsheet.getId();
  url += '&row=' + sheet.getLastRow();
  var message = 'New announcement submitted.\n' +
      'Title: ' + title +
      '\nDescription: ' + description +
      '\nApprove: ' + url;
  MailApp.sendEmail('emailaddress@blahblah.com', 'New Announcement', message);
}


function doGet(event) {
  var spreadsheetId = event.parameter['spreadsheetId'];
  var spreadsheet = SpreadsheetApp.openById(spreadsheetId);
  var sheet = spreadsheet.getSheetByName('Announcements');
  var row = event.parameter['row'];
  sheet.getRange(row, 3).setValue('Yes');
  var app = UiApp.createApplication();
  var label = app.createLabel();
  label.setText('The announcement was approved');
  app.add(label);
  return app;
}
4

1 回答 1

0

如果单击链接的用户不是脚本所在域的一部分,您将收到错误消息“抱歉,您请求的页面(或文档)不存在。请检查地址并重试。”继续运行,在本例中为“shawinc.com”。

于 2012-10-19T20:22:53.300 回答