Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

160
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!