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:
- Create a new Sheet named and Google Apps Script
- Code Google Apps Script with simple menu and functions, and save changes (see code below)
- Verified functions work
- 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'
- 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;
}
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