Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom function for Google Sheets not recognized by Test Deployment

I created a google apps script for Google Sheets with some simple custom functions. But when I Test the Deployment as an Add-on to a test Sheet. The custom functions don't work in the test sheet. Here are the steps I'm following:

  1. Create a new Sheet named and Google Apps Script
  2. Code Google Apps Script with simple menu and functions, and save changes (see code below)
  3. Verified functions work
  4. Deploy as Test Deployment with set to: 'Editor Add-on', 'Latest Code', 'Installed and Enabled'. And set test document to new empty sheet named 'Custom Geometry Functions Test'
  5. Select the Test Deployment and click 'Execute'. I see that the custom menu is added to the test sheet and it's working. But the custom functions don't work. I get an error saying 'Unknown function:'

Here's a link to the google sheet that contains the script: https://docs.google.com/spreadsheets/d/1lE-zvkxDZbjU1RU03CSZLywzv7gN6Ui3vWsRP5O4EeA/edit?usp=sharing

Here's a link to the test sheet: https://docs.google.com/spreadsheets/d/1SHcoNxtTLx74JqOnyVc8fqi5XRY2qFKMIvD39D5j5ss/edit?usp=sharing

code:

function onInstall(e){
  onOpen(e);
}

function onOpen(e) {
  SpreadsheetApp.getUi().createAddonMenu()
      .addItem('Info', 'showInfo')
      .addToUi();
}

function showInfo(){
  var ui = SpreadsheetApp.getUi();
  ui.alert("Fun with Custom Geometry Functions","This are some fun custom math 
functions",ui.ButtonSet.OK);
}

/**
 * Calculates the area of a circle.
 * @param {number} radius of the circle.
 * @return The area of a circle.
 * @customfunction
*/
function AREAOFCIRCLE(radius) {
  return 3.14159265359 * radius * radius;
}

/**
 * Calculates the perimeter of a circle.
 * @param {number} radius of the circle.
 * @return The perimeter of a circle.
 * @customfunction
*/
function PERIMETEROFCIRCLE(radius) {
  return 2 * 3.14159265359 * radius;
}
like image 985
Daniel Vaca Avatar asked Jul 22 '26 22:07

Daniel Vaca


1 Answers

I can confirm the issue. This is probably due to the fact custom functions run in their own auth mode AuthMode.CUSTOM_FUNCTION. In any case, this seems to be a known issue:

https://issuetracker.google.com/issues/36763437

  • Click +1 on the top of the page to let Google developers know that you're affected.

  • Click documentation feedback here https://developers.google.com/apps-script/add-ons/how-tos/testing-editor-addons to update documentation

like image 128
TheMaster Avatar answered Jul 25 '26 10:07

TheMaster