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

227
Vistas
How to fix type error in google app script

I have the following function in a google app script running on a google sheet.

function GetRecords(username) {
  var ss= SpreadsheetApp.getActiveSpreadsheet();
  var displaySheet = ss.getSheetByName("DISPLAY SHEETS");
  var getLastRow =  displaySheet.getLastRow();
  var gradeArray = [];
  for(var i = 2; i <= getLastRow; i++)
  {
    var gradeSheetName = displaySheet.getRange(i, 1).getValue();
    var gradeSheet = ss.getSheetByName(gradeSheetName);
    var getLastRowGrade =  gradeSheet.getLastRow();
    for(var y = 2; y <= getLastRowGrade; y++)
    {
      if(gradeSheet.getRange(y, 1).getValue().toUpperCase() == username.toUpperCase())
      {
        var grade = gradeSheet.getRange(y, 2).getValue();
        gradeArray.push([username.toUpperCase(), gradeSheetName, grade]);
      }
    }
  }
  return gradeArray;  
}

It was working fine up until yesterday, where it now returns the following type error:

TypeError: gradeSheet.getRange(...).getValue(...).toUpperCase is not a function
    at GetRecords(Code:17:47)

Any ideas on how to fix this?

Thanks

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Explanation:

getValue() can return Number, Date, Boolean, or String data type depending on the cell value. Your cell contained a non-string value so it cannot be converted to uppercase.

You could manually convert the value to String first:

gradeSheet.getRange(y, 1).getValue().toString().toUpperCase()

Sample:

enter image description here

Reference:

Class Range | getValue()

about 4 years ago · Juan Pablo Isaza Denunciar
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