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;
}