I'm creating a Gmail Addon and for some reason AppScript has stopped updating when I save my code. Up until last week I would make changes, save my code, refresh Gmail add the updates would be there. The addon is installed as a developer addon using the HEAD version.
First question, do I have to re-deploy or anything after making changes? As far as I can see in the documentation the approach above should work fine.
I'm using the Google Oauth2 library to login into an external service. It was all working fine last week and now I've just noticed these errors come up in the execution hints...
Method Properties.deleteProperty invoked in the global scope.
File: Storage
Line: 125
This function invocation will fail when the script is run as an Add-on in AuthMode.NONE.
Method Cache.remove invoked in the global scope.
File: Storage
Line: 127
This function invocation will fail when the script is run as an Add-on in AuthMode.NONE.
Method ScriptApp.getScriptId invoked in the global scope.
File: Service
Line: 36
This function invocation will fail when the script is run as an Add-on in AuthMode.NONE.
I don't have access to the files that the errors are referring too though so how am I supposed to fix them?
Also if there are errors in the execution hints will that prevent any updates to the code? Is that the reason I wouldn't be seeing my updates come through?
I know the updates aren't working because I'm seeing nothing in the logs where I was before.
Really appreciate any help. I've spent hours going through the docs, SO and the issue tracker trying to figure this out.
Related
When developing Google Apps Scripts (specifically for Sheets in my case), you can use the Debug button to step through code and inspect variables, or you can use the Logger to output debug info.
What I can't figure out, however, is if there is any way to do these things when functions are triggered through the sheet itself. For example, from a custom menu item which fires a function, or an onEdit() trigger.
It makes it very difficult to debug issues because, as far as I can tell, GAS simply fails silently. Nothing useful appears in the browser JS console either.
I'm writing this answer as a community wiki, since the issue was resolved from the comments section, in order to provide a proper response to the question.
As mentioned in the comments, you can use the Apps Script execution log in the script editor. You can use either the Logger or console logging service.
In addition, to test a trigger function and check if there are any errors, you can do the following:
Since you're using onEdit trigger, edit a cell in the sheet.
Go to the Apps Script project.
If there are errors, you can view the logs in the "Executions" section and you'll find a list of executions which you can filter by Failed and Time out.
Reference:
Apps Script mechanisms for logging
Since today morning, I am getting the below message while trying to run new App scripts on a new Google sheet.
Error An unknown error has occurred, please try again later.
My other App scripts attached to existing Google sheets continue to run fine. But if I create a new sheet and add even a plain simple function as shown below and try to execute this, I get the above error after it attempts to run it for some time and then gives up.
function Mytest()
{
}
I suspect that it is not able to bring the permission box which it use to bring up for any new script created. Till yesterday, once the permissions dialog box comes up and I used to give the permissions, the scripts use to run fine. But today it is not even bringing up the permission dialog box.
It looks like there is a outage going on with Google Apps Script when running new projects. I can see a couple of people reporting it in Google's public issue tracker.
It looks like it is only affecting new projects but most old projects are running fine. In the meantime you can add more info to the report to bring more attention to it. I have made some tests in 4 different accounts from different organizations and I can confirm I am also affected by this.
A couple users are reporting that it started to fix itself, and it looks like clearing cache and cookies from the browser may solve the issue (this is not a definitive solution but may work for you).
Only happens with Apps Script-managed Google Cloud Platform projects. Seems okay if you manually set the GCP project with the id using Resources > Cloud Platform Project...
I tried this because mine started with this error:
We're sorry, there was an unexpected error while creating the Cloud Platform project. Error code DEADLINE_EXCEEDED
I was having the same issue. Adding the script ID to the Library seemed to fix it.
Go to the "settings" option in the left menu of the script editor and copy the script id. Then click the plus icon next to the "Library" option and click "look up". Once the script is found, click "add" and run the script.
I have written some GScript that is called by a Google App (Awesome Tables).
How do I debug the GScript while it is running after being initiated by the Google App (I particularly want to see that values in variables as I step through the code)?
I found that Google Apps Script has a Logger Class. I used this to log messages when certain stages in my code was reached (some included variable values) and then emailed the whole log to myself. See https://developers.google.com/apps-script/reference/base/logger
I don't know of a way to do this. The best approach is probably to mimic the calling application by creating a test function in your Google Apps Script that calls the main function with the appropriate parameters. Then you can step through the code and see values using the debugger.
Try to check this Debugging part in the Google Apps Script documentation if it can help you.
It is stated here that there are some strategies for handling errors and investigating a script that is not running the way you expect.
Execution transcript
Logging custom messages
Using the debugger and breakpoints
For more information, check this Some Simple Debugging for Google Apps Script
So, I have a bunch of Google Apps Scripts that use the onOpen/onInstall functions to load a menu or do some minor startup stuff. All of them have been working in the gallery for quite some time.
Recently, and I'm not exactly sure of the time on this, something Google has updated has caused a problem where:
OnOpen doesn't seem to always execute on open
OnInstall fires but doesn't have access to functions in the script. Specifically, if you try to select a menu item, Apps Scripts brings up an error saying the function does not exists (but it does)
There is an incredibly crappy workaround for the user: install the script twice. Somehow this gets the functions registered and the onInstall gets the menu loaded. But this only works until the sheet is closed; then they have to install again.
So here is my questions:
Are other people having this problem, have they figured out a workaround?
Is this something Google has acknowledged and is getting fixed?
Does anyone know when this happened?
Finally, I'd like to suggest the idea of "freezing" the api for a script in production. IE. we place a variable at the top saying we are using API version XXX and that is the API that fires out Apps Script. This is the third time I've had scripts in production that were then broken by a Google update. At some point we need to be able to know that when we put something out to the world that it will continue to work. Users don't make the distinction between our mistake and a bug in the API, which means that we take the heat from these sorts of problems.
Looks like a bug
It appears to be a bug with triggers attached to scripts that are loaded externally. One way to fix it is to manually add and remove an onOpen event trigger.
Note: You don't need to keep the trigger because the existence of an onOpen in the code will add the trigger implicitly.
I'm having the same issue with a script I released in the 'Script Gallery'.
As for the onInstall trigger, I think you're SOL until Google fixes it.
I keep getting this error message when I try to view my deployed app.
Authorisation is required to perform that action
How do I get around the error?
Services in use in the script:
ScriptDB
UiApp
(I think that is all)
I can't find the answer in the documentation, so I would be very grateful for some help.
You need to go the script editor and attempt to run any function manually first.
A first authorization popup is shown when you first deploy as web app, but if you go and change the code accessing new services you have to re-authorize it.