我观看了一个YouTube视频,标题为“Google Apps EDU Fireside Chat环聊:应用脚本简介”,其中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;
}
答案 0 :(得分:0)
您将收到该错误,“抱歉,您请求的页面(或文档)不存在。请检查地址并重试。”,如果用户点击该链接不属于该域的一部分脚本正在运行,在本例中为“shawinc.com”。