Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

322
Vistas
setValue cannot change the latest data if its value is 'O'

I have a function that it will detect the change of google sheet when anyone write something into google sheet. However,there is a problem. It cannot change the latest data if its value is 'O'. It still can send mail,but setValue() just didn't work on the latest data.

Does anyone know how to fix this problem? Here is my sheet data.

enter image description here

function sentMail(confirm) {
  var spreadsheet = SpreadsheetApp.openById('XXXXXXXX');
  var sheet = spreadsheet.getSheetByName('QAAZ');

  var mail = "xxx@gmail.com";
  var title = "test mail"

  var lastRow = sheet.getLastRow();
  var lastCol = sheet.getLastColumn();
  var range = sheet.getRange(1,1,lastRow,lastCol);
  var values = range.getValues();

  var rowCount = 2;
  var colCount = 14;
  
  Logger.log(values [rowCount][colCount - 1]);
  Logger.log(lastRow);
  lastRow = lastRow + 1;

  for(rowCount = 1; rowCount <= lastRow + 1; rowCount++){
    if(values [rowCount][colCount - 1] == 'O'){
      if(values [rowCount + 1][colCount -1] == 'O'){
        sheet.getRange(rowCount, colCount).setValue('V');
        sheet.getRange(rowCount + 1, colCount).setValue('V');
      }
      else{
        sheet.getRange(rowCount, colCount).setValue('V');
      }
      GmailApp.sendEmail(mail, title, "test");
      Logger.log(values [rowCount][colCount - 1]);
    }
  }

  

  
}
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda