作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试创建一个脚本,在该脚本中提交另一个电子表格时会更新日期和其他信息,并且该工作表的 pdf 版本会发送给另一名工作人员,然后他们可以批准该工作表。当代码为我运行时,其他工作人员无法使用该脚本,因为尽管他们拥有所有文档的编辑访问权限,但他们不断收到“您无权访问所请求文档”的提示。
关于为什么会发生这种情况的任何想法。我希望员工能够运行的代码是:
function sendToResponse() {
var subject = sheet.getRange(3, 2).getValue();
var rowOfTargetSubjectInMasterSheet = rowOfTarget(subject);
var myLastYearGroupCell = countCellForTargetSheet(sheet, 12, 3);
var myLastPeriodLengthCell = countCellForTargetSheet(sheet, 12 + myLastYearGroupCell + 5, 3);
Logger.log(myLastYearGroupCell);
Logger.log(myLastPeriodLengthCell);
var stuGroup = sheet.getRange(12, 3, myLastYearGroupCell).getValues();
targetSheet.getRange(rowOfTargetSubjectInMasterSheet + myLastYearGroupCell + 2, 5, myLastYearGroupCell).setValues(stuGroup);
var lengthTeaching = sheet.getRange(17 + myLastYearGroupCell, 3, myLastPeriodLengthCell).getValues();
targetSheet.getRange(rowOfTargetSubjectInMasterSheet + myLastPeriodLengthCell + 2, 7, myLastPeriodLengthCell).setValues(lengthTeaching);
var lengthStaffing = countCellFor(teacherRow);
var staffing = sheet.getRange(teacherRow + 1, 1, lengthStaffing, 3).getValues();
targetSheet.getRange(rowOfTargetSubjectInMasterSheet, 8, lengthStaffing, 3).setValues(staffing);
var ptDays = sheet.getRange(teacherRow + 1, 5, lengthStaffing, 1).getValues();
targetSheet.getRange(rowOfTargetSubjectInMasterSheet, 12, lengthStaffing, 1).setValues(ptDays);
var lengthClass = countCellFor(classSheetRow);
var classes = sheet.getRange(classSheetRow + 1, 1, lengthClass, 3).getValues();
targetSheet.getRange(rowOfTargetSubjectInMasterSheet, 13, lengthClass, 3).setValues(classes);
var ctlName = sheet.getRange(4, 2).getValue();
var ctlEmail = sheet.getRange(5, 2).getValue();
var sltName = sheet.getRange(6, 2).getValue();
var sltEmail = sheet.getRange(7, 2).getValue();
var emailDate = targetSheet.getRange(rowOfTargetSubjectInMasterSheet, 16);
var sltResponse = targetSheet.getRange(rowOfTargetSubjectInMasterSheet, 17).getValue();
var cell = targetSheet.getRange(rowOfTargetSubjectInMasterSheet, 1);
var workingRow = cell.getRow();
if (sltResponse == '') {
var approve = url + "?approval=Approved" + "&reply=" + ctlEmail + "&r=" + workingRow + "&sltName=" + sltName;
var email = HtmlService.createTemplateFromFile('CTLRequestResponseSLTEmail');
email.sltName = sltName;
email.subject = subject;
email.CTL = ctlName;
email.approve = approve;
var response = email.evaluate().getContent();
MailApp.sendEmail({
to: sltEmail,
subject: 'Timetable 2020-2021: CTL Request for ' + subject,
htmlBody: response,
attachments: [SpreadsheetApp.getActiveSpreadsheet()]
});
var d = new Date();
emailDate.setValue(d);
};
}
function doGet(e) {
// Update Spreadsheet
var answer = e.parameter.approval;
var workingRow = e.parameter.r;
var d = new Date()
targetSheet.getRange(workingRow, 17).setValue(answer);
targetSheet.getRange(workingRow, 16).setValue(d);
//Email
var ctlEmail = e.parameter.reply;
var sltName = e.parameter.sltName;
GmailApp.sendEmail(ctlEmail, "CTL Request 2020-2021", "Thank you for submitting your CTL Request for 2020-2021. The form has been sent to your SLT Line Manager for approval.");
var app = HtmlService.createHtmlOutput(sltName + " thank you for your response.");
return app
}
我已部署为 Web 应用程序,并尝试以我自己和访问 Web 应用程序的用户身份执行应用程序,但均无效。
谢谢
法齐拉
最佳答案
如果您自己部署 WebApp:
Who has access to the app:
设置为Anyone
或Anyone, even anonymous
以确保任何用户都可以访问 WebAppGmailApp.sendEmail()
)都将代表您执行 - 即以您的名义执行如果您将 WebApp 部署为访问 Web 应用程序的用户
:
关于google-apps-script - Google Apps 脚本错误 : “You do not have permission to access the requested document” ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67228808/
我是一名优秀的程序员,十分优秀!