직장에서 사용하는 프로젝트 추적 시트를 기반으로 이메일 알림 시스템을 설정하려고합니다. 작업 상태가 K 열의 "완료"로 변경되면 이메일을 보내야합니다. 테스트 시트에서 작업 할 코드가 있는데, 실제 시트에 복사하면 getValue() 코드가 작동을 멈 춥니 다. 전자 메일은 if() 문을 기반으로 전송되므로 스크립트는 실행되지만 실제로는 작동하지 않습니다. 내가 라이브 시트의 소유자가 아니기 때문에 권한 문제인지 확실하지 않습니다. 충분히 설명 적이기를 바란다 - 나는이 일을하기 위해 자바 스크립트를 가르쳤다. 그리고 그것은 매우 가깝게 보인다. 그러나 나는 붙이게된다! 프로젝트 추적 시트의 모양은 screenshot입니다.getValue가 시트에서 작동하지 않습니다.
function emailUpdate(e) {
var emailInfoRange = sheet.getRange("B:O");
var edit = e.range.getA1Notation(); // Gets edited cell location
var editColumn = edit.substring(0,1) // Gets column of edited cell
var editRow = edit.substring(1,3) // Gets row of edited cell
if(editColumn == "K") { // gets all relevent information needed for email
var taskTypeCell = emailInfoRange.getCell(editRow,1);
var taskType = taskTypeCell.getValue();
var requestedByCell = emailInfoRange.getCell(editRow,3);
var requestedBy = requestedByCell.getValue();
var emailRequestCell = emailInfoRange.getCell(editRow,4);
var emailRequest = emailRequestCell.getValue();
var projectIdCell = emailInfoRange.getCell(editRow,5);
var projectID = projectIdCell.getValue();
var taskDescriptionCell = emailInfoRange.getCell(editRow,6);
var taskDescription = taskDescriptionCell.getValue();
var claimedByCell = emailInfoRange.getCell(editRow,9);
var claimedBy = claimedByCell.getValue();
var taskStatusCell = emailInfoRange.getCell(editRow,10);
var taskStatus = taskStatusCell.getValue();
if(taskStatus == "Done") {
if(emailRequest == "Yes" || emailRequest == "yes") { // Determines if status is "Done", and email notification is "Yes" or "yes"
var emailAddress;
var getEmailAddress = function(personelArray) { // Defines function to search email address arrays for the one that belongs to requestedBy
for (var i = 0; i < personelArray.length; i++) {
if(requestedBy === personelArray[i]) {
emailAddress = personelArray[i+1];
} } }
// Searches through all email arrays to find the one belonging to requester
getEmailAddress(specialistsAndEmails)
getEmailAddress(coordinatorsAndEmails)
getEmailAddress(managersAndEmails)
// Sends email
MailApp.sendEmail(emailAddress,
"AUTOGEN: " + taskType + " for " + projectID + " " + taskDescription + " completed by " + claimedBy + ".", "This email has been automatically generated by an edit to the work available sheet. \n"
+ "PLEASE DO NOT REPLY");
} else (Logger.log("No email requested"))
} else (Logger.log("Status not changed to done"))
} else (Logger.log("Update not to status cell"))
}
시트를 편집 할 때 스크립트 편집기에서 실행 결과 (보기> 실행 내역)가 어떻게 표시됩니까? 권한에 관해서는 시트에 대한 편집 권한이 있으면이 스크립트를 실행할 수 있어야합니다. 마지막으로, 하루에 보낼 수있는 전자 메일 수에 대한 할당량이 있으며, 할당량을 초과했는지 알고 있습니까? –
실행 대본에 따르면 스크립트 전체가 진행됩니다. 이메일 할당량에 대해 전혀 알지 못하지만 어쨌든 초과해서는 안됩니다. – Erin