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

159
Vistas
Getting null when getting value from spreadsheet if special characters where used in App Script

I'm not a good programmer or English speaker, sorry.

I try to access a Google spreadsheet with app script and from fixer .gs I can get the record I want but at the same time switching it to javascript the console returns "null".

This only happens when there are special characters in the fields I'm looking for, such as colon.

function recullEntrades(){
  const ss = SpreadsheetApp.openByUrl(url);
  const ws = ss.getSheetByName("Dades");
  Logger.log(ws.getRange(2,1, ws.getLastRow()-1,7).getDisplayValues())
  return ws.getRange(2,1, ws.getLastRow()-1,7).getValues();
}

This is ok in the Logger but then,

function miraEntrades(entrades) {
  console.log("entrades: " + entrades);
}

$('#vomita').click(function(){
  google.script.run.withSuccessHandler(miraEntrades).recullEntrades();
})   

In the chrome console i get "null", this is not happening if i not use colon.

Thanks.

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

0

Like pointed above by @Josep, it looks like you're logging the values using getDisplayValues but you're returning the values using getValues.

According to the Apps Script documentation:

getDisplayValues

Returns a two-dimensional array of displayed values, indexed by row, then by column. The values are String objects. The displayed value takes into account date, time and currency formatting, including formats applied automatically by the spreadsheet's locale setting. Empty cells are represented by an empty string in the array.

getValues

Returns a two-dimensional array of values, indexed by row, then by column. The values may be of type Number, Boolean, Date, or String, depending on the value of the cell. Empty cells are represented by an empty string in the array.

Therefore, depending on the exact use-case, you might benefit from returning the values using the getDisplayValues method instead.

Reference

  • Apps Script Range Class - getDisplayValues();

  • Apps Script Range Class - getValues().

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