Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Why am I getting this error: TypeError: SpreadsheetApp.getSpreadsheetById is not a function

This is surely a newbie question but I am breaking my head over it. I just don’t understand what I’m doing wrong!
I have the following script which is incomplete and definitely incorrect. But my issue is that when I run it, I get the following error:

TypeError: SpreadsheetApp.getSpreadsheetById is not a function

This is the script:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

function matchRow() {
  var ss = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  var ts = SpreadsheetApp.getSpreadsheetById('1Sq5prZI4a_UwesPTUQLnmXvtpJClyMcMlHM-m3JrE6g').getSheetByName('Quiz advertiser');
  var countryIndex = ('Spain', 'Germany', 'France');
  var getLastRowByMatch = matchRow();
   if (ss.countryIndex = 'Spain');
   getss.LastRowByMatch;
}

What am I doing wrong?

>Solution :

SpreadsheetApp.getSpreadsheetById doesn’t exist. Instead of

var ts = SpreadsheetApp.getSpreadsheetById('1Sq5prZI4a_UwesPTUQLnmXvtpJClyMcMlHM-m3JrE6g').getSheetByName('Quiz advertiser');

use

var ts = SpreadsheetApp.openById('1Sq5prZI4a_UwesPTUQLnmXvtpJClyMcMlHM-m3JrE6g').getSheetByName('Quiz advertiser');

By the way, the lines after the referred one doesn’t make any sense. It looks that you have to spend some time reviewing https://developers.google.com/apps-script/guides/sheets.

References

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading