My Triggers no longer work. I have two different google sheets with triggers setup. One sheet has a daily trigger that is set to fire between 9-10am. The other sheet has two triggers, one fires on a form submit and the second trigger fires on change. These had been working fine for a solid year before they up and stopped working a week or two ago.
For both of the google sheets, I have tried deleting and re-adding the triggers. For the one that has the daily timer, I have tried changing the time of day around also. No luck on them firing own their own. If I go to the Run Menu and run the function manually it works fine. I'd rather avoid having to create new google sheets as links to these sheets are published to users in my domain and are in production.
ie.
function updateScores()
{
Logger.log("Function started");
/*
all of my code here....
*/
}
When I manually run the function I see the "Function started" message in the logs along with all my other Logger.log statements I have throughout the code. Calculations are done correctly, emails sent, etc. The code itself works fine.
Actually, I've seen a couple of issues regarding triggers not working posted just recently in google-apps-script-issues tracker - Issue 6226 and the latest is Issue 6244.
As advised in this SO post - Google app script trigger not working, after checking the logs which you already have done and as you mentioned "The code itself works fine", you may post the issue in Apps Script Issue Tracker .
Related
The objective is to transfer data from Google Calendar to a Google Sheet whenever the calendar is edited. For this we need a script that transfers the data, and need to set up the Calendar trigger.
Thanks to Oleg Valter and his excellent and exhaustive explanation how to create the script on this page:
Google calendar events to Google spreadsheet automatic refresh onEdit
the data transfer already works fine when the script is started from the Google sheets. I use a modified version of Oleg's script, which works well, and I am not sure if it would make sense to re-post it here (since that is not the problem).
I have tried to create the trigger with Oleg's funtion first:
/**
* Installs Calendar trigger;
*/
function calendarTrigger() {
var trigger = ScriptApp.newTrigger('callback name here')
.forUserCalendar('calendar owners email here')
.onEventUpdated()
.create();
}
but the trigger did not fire when I have added a new event on the calendar. Checked the triggers connected to the project, and the trigger created by the above function was there. Checked the Executions and nothing showed up.
Then I have manually deleted the trigger, and manually crated a new one following the instructions under "Managing triggers manually" section of this page:
https://developers.google.com/apps-script/guides/triggers/installable#google_apps_triggers
The trigger was created again, which basically looked the same as the one created by the above function, but it still did not fire when tested.
Now I am stuck and have no idea what else to try. It supposed to work, but it is possible that I have missed setting up something else that might be required for this to work.
I am using a simple Google account connected to a single email address (not a business suite). Never had any problems with the other triggers related to the sheets before that I could not resolve (sometimes the platform refuses to work as it should, but then later things get back to normal).
I would highly appreciate any advice about what else to try, or if you know what the problem is, even better.
Thanks in advance,
Zoltan
Well, after some trial and error based on ziganotschka's kind answer (thanks again) found the problem. It is caused by a bit of confusion about what the
.forUserCalendar('calendar owners email here') and the
Calendar ID supposed to be.
On my Calendar account there are several calendars, but two are of interest for us here:
"Main Calendar" which is the default calendar associated with the account. If everything else is deleted, then this will remain.
another calendar that I have added for the very purpose to be connected to the spreadsheet, and named it "Auto Billing" (only this is checked and displayed).
The Main Calendar has this on the Settings page (changed my email address):
Integrate calendar
Calendar ID
myAddress#yahoo.com
The Auto Billing calendar has this on the
Settings page (changed the ID):
Integrate calendar
Calendar ID
svj8tu1o458a9s1488xxxxxxxx#group.calendar.google.com
My intent was to use a custom created calendar for this purpose instead of using the default Main Calendar, because this might be full with all kinds of events.
Therefore when the trigger is created manually
svj8tu1o458a9s1488xxxxxxxx#group.calendar.google.com
should be added in the field "Calendar owner email" instead of the calendar owner's email address.
When the trigger is created from script using the above snippet, then
.forUserCalendar("svj8tu1o458a9s1488xxxxxxxx#group.calendar.google.com")
should be used.
In the script that transfers the data from the Calendar to the sheet the
var Calendar = CalendarApp.getCalendarById("svj8tu1o458a9s1488xxxxxxxx#group.calendar.google.com");
should be used. This way the trigger will work when events are edited on the Auto Billing calendar.
Thanks for the guidance Ziganotschka, and also big thanks to Oleg for the original script. Hope this debugging will help others as well.
Google Calendar trigger is a feature for the Google Calendar
It does not work for "myaddress#yahoo.com" calendars
I'm having an issues with a "Sheets Addon" i am working on. I know how to create triggers in a normal script, but what I'm trying to do is create a trigger within an Addon that will call back to a function within that same addon. I want this to be a timed based trigger, every 1 or 2 hrs as the options.
If I create the trigger via sheets scripts, it all works fine, but using the same exact code for the addon.. it fails 100% of the time, but with no specific error, or at least not that i can get to easily.
I'm assuming there is something different to be add to the code to make a new trigger code work within an addon, but not sure what it is. any help would be greatly appreciated.
EDIT 12/4/2019::
example snippet... if i place this into the sheets script, and run it (from the sheet and not from the addon) it works fine. The trigger gets added and calls to the function with no issues. However when i run it from the sheet via the addon, the trigger still gets created but error our when processing.
function testCreateTrigger() {
ScriptApp.newTrigger('testRunTrigger')
.timeBased()
.everyHours(1)
.create();
}
One thing i'm noticing is that the Trigger for the sheet (non-addon) is created with Project name, Deployment, Event, Function ... all populated, but when i run it via the addon, the Deployment is blank.
Also installed the google salesforce addon which has a schedule feature which adds as a trigger, but that addon somehow creates the trigger with a "Blank" value for Project, Deployment, and Function ..but still knows what function within the addon/script to call to process. I think that's what I'm missing, how to create a trigger, from a function, within an addon.
I have been using a number of triggers based on form submission to a google sheet. Since yesterday the triggers have stopped working.
I have
unlinked and re-linked the form and sheet.
created a new response sheet.
recreated my scripts,
tried macros ( its a simple operation to sort the google sheet responses and send the top most response to another sheet )
the form submit trigger doesnt work. so to test I setup time based triggers. they seemed to work but stopped at 5 am this morning.
I can run the script manually and works fine but triggers do not run.
There was nothing in the logs. each trigger just stopped firing
Can anyone advise ?
Many thanks
I'd like to confirm the issue
Problem
installable trigger onFormSubmit from GoogleSheet stopped executing.
installable trigger onMinute from the same Spreadsheet still working and showing logs.
Logs are empty here:
https://script.google.com/home/projects/PROJECT/executions
Solution?
My attempts to resolve the issue:
Delete and create trigger again
Change the source code
Create 2 same triggers.
Possible other tests:
Create trigger from another account
Create a trigger with no code to test if it could execute at all.
Conclusion
In the end, one of my newly created triggers started the execution again.
I do not know what fixed the problem: changing the function text OR creating/deleting triggers OR some external fix on the Google side.
If some have more issues, please report the issue here:
https://issuetracker.google.com/savedsearches/566222
I have a fairly simple Google Apps Script that runs every time an answer to a Google Form is submitted (by using "on form submit" trigger). The script does some simple manipulations and updates a Google SpreadSheet. Recently I needed to change that script to run manually and not on form submit, so I deleted the trigger. However the script still kept running on every form submit!
There are other users who might have the same trigger setup, since the spreadsheet and the code are shared. Is there a way to completely delete all the triggers for a particular script? In the meantime I just renamed the script and that has solved the issue, however this is a bad solution.
Search on stackoverflow did nothing, seemingly similar questions are resolved through clearing "Resources -> All your triggers...", which only does it for your user. Question is how to remove/edit all the triggers for the project, even from other users.
Here's how to stop any orphaned Google Script.
Go to https://security.google.com/settings/security/permissions
Click the script / project name you wish to uninstall
Next click Remove and you are done.
I have a spreadsheet script using google spreadsheets that was firing on a daily trigger. Everything was running fine until a few days ago and suddenly it stopped working. The script sends me an email every day, around midnight. I was able to send a test email today but the operation that pulls data from my spreadsheet doesnt seem to be able to send the email. Ran it through the debugger and everything appears to be working fine. Does anyone know why something like this might happen?
First, you need to figure out whether or not your trigger is being invoked. If yes, click on notifications in the triggers window to set it up so that you receive an error email immediately. This way you'll see if your script gets any errors which might be useful in determining the next step.