Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

315
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda