Custom function for Google Sheets not recognized by Test Deployment
Asked Answered
P

1

2

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;
}
Platoon answered 4/2, 2024 at 6:58 Comment(0)
R
3

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

Recessive answered 10/2, 2024 at 6:48 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.