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

143
Visualizações
JavaScript (Google Script Custom Function) Not Reading Array Properties

I am writing a simple custom function to iterate through a column, and if a cell has a certain value, to check the value of a different column in that same row. If the value in that cell has a certain value, increase a counter. For some reason, I am getting a TypeError when trying to read a specific column.

Here is the error message I am getting:

TypeError: Cannot read property '0' of undefined (line 22).

Line 22 being: if (data[row][0] === "maxcaza@gmail.com") {

Does anyone have any solutions? Thank you.

  
  var sheet = SpreadsheetApp.getActive().getSheetByName('Form Responses 1');
  var lastRow = sheet.getLastRow();
  var lastCol = sheet.getLastColumn();
  
  var range = sheet.getRange(2, 2, lastRow, lastCol);
  var data = range.getValues();
  
  var count = 0;

  data.forEach(function (row) {
    if (data[row][0] === email) {
      if(data[row][1] === meeting){
      count += 1;
    }
  }
  });
  return data;
}
about 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

Instead of

data.forEach(function (row) {
    if (data[row][0] === "maxcaza@gmail.com") {
      if(data[row][1] === "Leadership"){
      count += 1;
    }
  }
  });

try

data.forEach(function (row) {
    if (row[0] === "maxcaza@gmail.com") {
      if(row][1] === "Leadership"){
      count += 1;
    }
  }
  });

The above assumes that the first column might contain "maxcaza@gmail.com" and the second might contain "Leadership"

about 4 years ago · Santiago Trujillo Relatório
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