I'm using google spreadsheet with Google Apps Script.
but it gives me error message too easily. like this
Error
Script invoked too many times per second for this Google user account. (line 0).
Is there any way to avoid the error? (except the way reduce function call)
or alternative Spreadsheet program that support Javascript function define?
As noted in the documentation you can work around this by ensuring that your function supports ranges, and the function on a range. See also the section on Optimization on the Custom Functions in Google Sheets page.
To create a custom function you should use Google Apps Script, it's the only way. Regarding the way to avoid the error, there are several things that could be done but to be certain about what is required in your case you should add more details.
Related
I am creating an new Google Apps Script about GDrive/New/More/Google Apps Script.
The script is running perfect and on the end my intention is to send a Info on the Desk.
When I am using this line:
Browser.msgBox("TEST");
I get the error back:
Exception: Cannot call Browser.msgBox() from this context; have you tried Logger.log() instead?
Logger.log can't be the solution, because I don't see the result on the desktop, but only in the log files.
Is there another solution or is it possible to get a simply example what I can do?
In this case Browser.msgBox is a method for the Browser class, this class is specifically meant to be used in Spreadsheets as stated in the documentation:
Class Browser
This class provides access to dialog boxes specific to Google Sheets.
The methods in this class are only available for use in the context of a Google Spreadsheet.
If you want a notification you could use either the Browser.msgBox method or the Toast method, either way they both need to be applied in a Spreadsheet in order to work.
Iv'e written a custom google sheet function using Google Apps Script, and i would like to share it with another spreadsheet user, but i do not want to share the functions source code.
I've converted the Google Apps Script to a project, but now i have no idea how to link the project back to my sheet, so the function will work again.
I also do not want to publish the AddIn to the marketplace.
Test As Addin also doesn't work, the sheet is opened in a new tab, but the cells with the custom function says #NAME?.
What am i missing?
Explanation / issues:
The error #NAME? indicates that you are trying to use a function
that does not exist. As you also mentioned, this function does not
belong to the active spreadsheet but on a different project.
Unfortunately, it is not possible to share a custom function with other spreadsheets directly.
Possible Workarounds:
You can create an add-on.
Another workaround solution would be to create a library. That is a great alternative and the documentation is quite straightforward.
Related:
Creating add ons in Google Apps Script
How to call library function as custom function from spreadsheet formula?
Is it possible to call any of the Google Sheets formulas from within your own Google Apps script custom function? If so, how?
It obviously doesn't work to merely use the formula name like you would inside the sheet. Like this, which is what I was hoping would work:
function myCustomFunction() {
return TDIST(1,30,1); // calling =myCustomFunction() does not work due to TDIST giving a ReferenceError, even though =TDIST(1,30,1) works inside the spreadsheet
}
But since Google's built-in formulas probably rely on some JS implemented functions, it would be strange if there wasn't an API so that we could reuse those functions easily. I've looked at the Google Sheets API reference, but it seems made for calling your custom functions from external services. It seems you may call Google's own formulas through such a POST request. But that seems terribly cumbersome, when you ought to be able to refer to them directly from within your custom script which is tied to the specific Google Sheet environment anyway. If not, then what is the least roundabout way of using those inbuilt formula functions from within a custom function?
This has been a feature request since 2011 and has been declined by Google citing inter team issues.
Status: Won't Fix (Infeasible) by ev....#google.com
We have requested this of the Spreadsheet team, and are marking as "Won't Fix" for now.
Apparently, The spreadsheet team hasn't responded yet. A related product forum post states that Google has no intention of integrating spreadsheet functions with scripts.
I want to write a Google Apps Script to generate a list of the IDs of the scripts bound to certain spreadsheets.
I cannot find a way to programmatically, via GAS, get the ID of a bound script.
If I have a spreadsheet object, I have methods like getId to get the ID of the spreadsheet, but not the bounded script.
Using the DriveApp, I can find standalone scripts using DriveApp.getFilesByType('application/vnd.google-apps.script') but not bound ones!
Any suggestions?
Unfortunately (by my own research) this is not currently possible. I have been wanting to programatically identify and access bound scripts for several years, I look into it periodically, I've always come up empty handed.
Haven't found any Google documentation explicitly on the topic, still hoping this hole gets filled eventually.
I have now written a number of different functions in Google Apps Script that I am using on a growing number of Google Spreadsheets.
Every time I make a small edit to one of these functions I then have to go into each spreadsheet and make the same correction.
Is there a way to "import" the functions to each spreadsheet so that I only have to edit the one "master" function and it is then updated on every spreadsheet?
Google has just release a new feature called Libraries, it is an elegant way to do what you're asking for. Here is the documentation, read it attentively because it's a multi-step process.
See this page for how to create and share functions in your sheets using Google Apps Scripts. The scripts are written in javascript and there are some limitations on how they can be used.
https://developers.google.com/apps-script/guide_writing_scripts#CustomFunctions