0
votes

I found a solution - I disabled the New Apps Script runtime powered by Chrome V8 and that allowed the script to run just fine. Thank you player0 and Cooper for your help.

I am running a script on Google Sheets that when we select completed from a dropdown box it will add the date to the cell next to it, and will email the entire row to the email in the designated column and move that row to another spreadsheet. The trigger was working for our entire office, but now the trigger only works for me and no one else. I have tried adding the trigger manually, but that still doesn't work. They will get a prompt to click yes or no on sending the email, but the date will not get added and the email will not be sent and the row will not get moved to the other spreadsheet. I will attach the script. PS, I am getting this error from the other people in the office -

"insertId": "-b34c8mev3dmh", "jsonPayload": { "serviceContext": { "service": "AKfycbyWSN3cTy8EFQa-O0BdEkD1-mv2Ch0_QJyGdxwARQ" }, "context": { "reportLocation": { "functionName": "onEdit", "filePath": "Code", "lineNumber": 3 } }, "message": "TypeError: Cannot read property 'columnStart' of undefined\n at onEdit(Code:3:14)" }, "resource": { "type": "app_script_function", "labels": { "function_name": "onEdit", "invocation_type": "unknown", "project_id": "project-id-7782795119186644705" } }, "timestamp": "2020-03-03T19:26:06.684Z", "severity": "ERROR", "labels": { "script.googleapis.com/process_id": "EAEA1GOy-5ZVtkWzLmBjIDEppHWx8s_53wy3z-YwpeR7_qYPiFhBieuyZpGnXpmAoAn3iRsKw7yVqE1DzHTMxoOKX-AdlvXIDwF6fMvntASIvF9nk-llZAP7XmG4ZySKOflqcAbimliGEF4nEjkfw_cdILTNgTesQpjOaGTvdI6GhGjn4M3bxxlEQ7yDOgcryfEZpuznnxRTphSL0KsMeoR1NgJ75HNhNtg6-M-Uj_-nFVF4jgHjcFLsO3-AuctQgpKzM7vCu-5uptzCiMl_GoLSW_IztLa2RoWEiYp0", "script.googleapis.com/user_key": "AJBqszan4nKoGMzVONs0MJNTlfxnM27ajlvZlz1Zgk0gT3p+b6sGQERsGNxTDk0oSVmVtWCL6r0G", "script.googleapis.com/deployment_id": "AKfycbyWSN3cTy8EFQa-O0BdEkD1-mv2Ch0_QJyGdxwARQ", "script.googleapis.com/project_key": "MKysurstsXJM-RhbK-YQe446zZFpi0V11" }, "logName": "projects/project-id-7782795119186644705/logs/script.googleapis.com%2Fconsole_logs", "receiveTimestamp": "2020-03-03T19:26:07.288469136Z"

function onEdit(e) {
// we need to be in column 13 in order to do something (at all)
if(e.range.columnStart === 13) {
var s = e.source.getActiveSheet();

// only continue if it's completed and where in the correct tab
if(e.value == "Completed" && s.getName() == "Open Requests") {
  var r = e.range;
  var userEmail = r.offset(0,-9).getValue();
  var name = r.offset(0,-7).getValue();
  var subject = "Technology Request for " + name;
  var body = "Your request has been completed by " + r.offset(0,-1).getValue();    

  body += "\nfor -  " + r.offset(0,-7).getValue();
  body += "\nby doing the following: " + r.offset(0,-2).getValue();
  body += "\nOriginal problem was stated as: " + r.offset(0,-4).getValue();

  // show dialogue
  var ui = SpreadsheetApp.getUi();
  var response = ui.alert('Are you sure you want to send this email to ' + userEmail + '?', 'Subject: ' + subject + '\n\n' + body + '\n\n\n', ui.ButtonSet.YES_NO);

  // process the user's response.
  if (response == ui.Button.YES) {
    MailApp.sendEmail(userEmail, subject, body, {name:"Technology Dept"}); 
  }

  // add time stamp
  e.range.offset(0, 1).setValue(new Date());

  // move the row elsewhere 
  var numColumns = s.getLastColumn();
  var targetSheet = e.source.getSheetByName("Closed Requests");
  var target = targetSheet.getRange(targetSheet.getLastRow() + 1, 1);
  s.getRange(r.rowStart, 1, 1, numColumns).moveTo(target);
  s.deleteRow(r.rowStart);


} 
} 
1
your coworker needs to authorize the script for himselfplayer0
Give them a function to run. It can even be a function that doesn't do anything so that they can be given the opportunity to authorize the scopes.Cooper
player0 - How does he authorize the script himself?Tommy Garcia
Cooper - How do I give them a function to run?Tommy Garcia
I just laid the answer as a community Wiki, if you want to actually provide a more detailed solution of how you solved your problem feel free to create an answer so I can delete mine.Raserhin

1 Answers

1
votes

The problem was related to the automatic switch to the new v8 runtime .

Going back to the old runtime has solved the problem, If you want you can actually report this bug to Issue Tracker.