Home > Enterprise >  Google Apps Script: Can't Find Definition of Methods
Google Apps Script: Can't Find Definition of Methods

Time:12-27

I am trying to find the definition of different methods using the Google Apps Script editor. To do so, I click on and/or highlight a particular definition (e.g., "setBackground", "SpreadSheetApp" or "getRange") and then click on either "Go to Definition" or "Peek >> Peek Definition".

Either way, I always get the same response:

For example:

* No definition found for setBackground

* No definition found for SpreadSheetApp

* No definition found for getRange

This is true whether or not I use the keyboard shortcut or right click as explained above. This happens regardless of which browser I use:

  • Brave
  • Chrome
  • Edge
  • Firefox

I should note that I am using a Windows 11 machine.

Any idea why this is happening and how to fix it?

Thanks

Screenshots

Right Click

enter image description here

Result

enter image description here

CodePudding user response:

The commands you mention look for the definition in your script project. Methods that belong to SpreadsheetApp and other Google APIs are not defined in your script project but in Google's libraries, whose source code is not available.

The easiest way to see the documentation is to enter the method name followed by an open parenthesis, as in SpreadsheetApp.openByUrl(. You can also insert a comma in the arguments list to view the same.

Yet another way is to use the Show Definition Preview Hover command. It is accessible through F1. See the New Apps Script Editor guide by Ben Collins.

  • Related