gpt4 book ai didi

google-apps-script - Google Apps 脚本错误 : “You do not have permission to access the requested document”

转载 作者:行者123 更新时间:2023-12-05 06:01:24 26 4
gpt4 key购买 nike

我正在尝试创建一个脚本,在该脚本中提交另一个电子表格时会更新日期和其他信息,并且该工作表的 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: 设置为AnyoneAnyone, even anonymous 以确保任何用户都可以访问 WebApp
  • 请注意,所有请求(例如 GmailApp.sendEmail())都将代表您执行 - 即以您的名义执行

如果您将 WebApp 部署为访问 Web 应用程序的用户:

  • 确保您为代码运行的电子表格设置共享权限,使所有用户/您想要运行 WebApp 的用户都具有编辑权限

关于google-apps-script - Google Apps 脚本错误 : “You do not have permission to access the requested document” ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67228808/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com