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

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

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 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!