Rehman Leghari
Rehman Leghari

Reputation: 1

Deployment not working upon switching accounts

I'm currently working on a Google Sheet that receives emails, and uses an app script to automate sending confirmation emails back. However, the email being used to send these confirmation emails out is my personal email. Upon trying to switch to my work email, I get an error each time I try to manage deployments. The error reads "Something went wrong Please reload the page to try again." I get this error each time I click any of the options on the deployment drop-down menu.

I've cleared my cache, tried incognito mode, checked my editor status, and checked Apps Script in my security settings. I am not entirely sure what could be causing this problem.

the following is my code

var sheetName = 'Sheet1';
var spreadsheetId = '1p_uNtFvZHPdIJetkN-YouPaek4JOg4mFHjqKIFcs-gw';
var flagColumn = 3;  // Use column C as a "trigger flag" column.

function checkForNewSubmission() {
  try {
    var sheet = SpreadsheetApp.openById(spreadsheetId).getSheetByName(sheetName);
    var lastRow = sheet.getLastRow();
    var flagValue = sheet.getRange(lastRow, flagColumn).getValue();

    if (flagValue !== 'Processed') {  // Check if the flag is not set
      var firstName = sheet.getRange(lastRow, 1).getValue();
      var recipientEmail = sheet.getRange(lastRow, 2).getValue();

      if (recipientEmail) {
        Logger.log('New submission detected. Sending email...');
        sendEmailNotification(firstName, recipientEmail);
        sheet.getRange(lastRow, flagColumn).setValue('Processed');  // Set flag to avoid reprocessing
      }
    }
  } catch (error) {
    Logger.log('Error in checkForNewSubmission: ' + error.message);
  }
}

function sendEmailNotification(firstName, recipientEmail) {
  try {
    Logger.log('Preparing to send email to: ' + recipientEmail);
    var subject = "Thank you for completing the assessment!";
    var body = `Hi ${firstName},\n\nThank you for completing our assessment. Your responses have been recorded successfully. If you have any questions, feel free to reach out.\n\nBest regards,\nThe Clean Divorce Team`;

    GmailApp.sendEmail(recipientEmail, subject, body);
    Logger.log('Email successfully sent to: ' + recipientEmail);
  } catch (error) {
    Logger.log('Error sending email: ' + error.message);
  }
}
function onEdit(e) {
  Browser.msgBox('testing');
}

Screenshot of error message: Something went wrong

Upvotes: 0

Views: 34

Answers (0)

Related Questions