We are working on Google Calendar Add-on and need some help regarding Add-on development. We are using the triggers to notify the us whenever there is any create/update/delete happen on the google calendar. So, there is any create/update/delete event that occurred into the user calendar then the trigger should notify our service with data but in our case, it is not working as expected due to which incident occurred. It is giving 1000's of notification without actually changing in the event.
We are using Triggers->Installable Triggers for the notification service.
Related
First of all, i am new to Google Workspace and this is the first time i am developing an addon.
I am trying to develop a Google Workspace(gsuite) Addon using Google Apps Script,
My main objectives are:
Whenever i create/save/update an event in Google Calender, i want to make an alert asking for ok and cancel, if i click cancel the event should not be created and if i click ok then the event should be created and the script function should call my API endpoint with the following parameters:
{
summary: summary_of_the_event,
created: event_created_or_updated_date,
googleCalendarId: calender_id
}
Here is the reference to Apps script Google calender:
https://developers.google.com/apps-script/reference/calendar/calendar-app
I appreciate the help.
Some thoughts about calendar add-ons
CalendarApp features the installable calendar trigger with the specification:
Calendar triggers fire when a user's calendar events are updated (created, edited, or deleted).
Installble triggers can be used in Google Workspace add-ons
Howver, this installable trigger only fire after the event has been created / updated, so it can help you to cancel event creation, but rather no manually delete the event a posteriori.
Mind also that the when the trigger fires, it does not give you any information about the created / updated event - you have to manually find this event e.g. by querying for the least created / updated event in user's calendar.
Google Workspace Calendar add-ons feature the manifest trigger for updating calendar events calendar.eventUpdateTrigger
Thereby:
This trigger only fires if the user makes one or more of the following edits:
Adds one or more attendees.
Removes one or more attendees.
Adds or switches to a different conferencing solution.
Google Workspace Calendar add-ons also feature the manifest trigger calendar.eventOpenTrigger
It fires when you open an event (this is what you want!).
However, this work only for already existing events - not when a user opens the Calendar UI interface to create a new event
Instead of letting a user create / update events through the regular Calendar UI, you can use Card Service to create a custom add-on interface where the user can specify that he wants to create an event
Within the card interface, it is easier to implement an ok / cancel functionality (as a card) and then (in case "ok" is clicked) create an event for the user programmatically.
I have a Google Forms Quiz linked to a Google Sheet and an Apps Script 'From spreadsheet - On form submit' trigger linked to an Apps Script. Intermittently, this trigger fires twice causing a problem for my application.
I thought multiple versions of my AppScript may have inadvertently been deployed in parallel. But I have made sure to delete all other versions and 'Deploy as web app...' using a new version number with 'Only myself' having access to the app.
I have also tried using a lock in the script to limit execution to one at a time and have tested whether double-clicking the 'Submit' button on the Google Forms Quiz will cause this behaviour.
I would expect the trigger to fire once per Google Forms Quiz submit button press.
In the end the solution to this problem was to handle the spurious double OnSubmit events by calling SpreadsheetApp.flush(); to ensure that my spreadsheet changes were committed before processing any second firing of the OnSubmit event. In this way my application was able to handle the issue.
Google Apps Script allows scripts to be triggered by a variety of events; see here.
I'd like to update the tag on an email (in Gmail) when the user marks a task completed (in Google Tasks) but there doesn't seem to be a trigger for this.
However, Zapier is able to trigger on these events somehow:
supported triggers
So it seems like this trigger must exist.
Is there a way to do this other than using Zapier?
Unfortunately Zapier (in addition to costing money) only allows you to add tags to Gmail messages, not remove them -- so one can't (for instance) change a message tag from [uncompleted-task] to [completed-task].
As of this writing (2018-05-15), Google Apps Script does not support a trigger to track a task's status.
I suspect that Zapier is polling the status of the task via the Task API; ie. periodically checking the status property of the task and firing an event once the status changes to complete.
You can do the same (with time-based triggers) using the Task API as an Advanced Service in GAS:
https://developers.google.com/apps-script/advanced/tasks
https://developers.google.com/tasks/quickstart/apps-script
Can someone accurately describe the trigger criteria for Gmail Add-on scripts? Apparently, the trigger is not invoked each time the user navigates between Gmail conversations.
The only documentation I can find is https://developers.google.com/gmail/add-ons/how-tos/building#note1, which states
the only contextual trigger type available is unconditional, which triggers for all emails regardless of content.
I interpreted this to mean that the trigger is invoked every time the user navigates to a different gmail conversation, however, that is not the case:
The first time I navigate to a some Gmail conversation, the add-on trigger fires. And when I navigate to another conversation using the the “Newer” or “Older” angle-bracket button, the trigger is again invoked for the new conversation. But when I navigate back to the first page using an angle bracket button, the add-on trigger does not fire. (Easy enough to show this by displaying a timestamp when each UI card is created.) There seems to be some kind of internal caching going on — is there any way to disable this, or otherwise run my add-on script each time the user navigates between Gmail conversations?
you can use ActionResponseBuilder.setStateChanged(), to clear the cache
link: https://developers.google.com/gmail/add-ons/how-tos/interactions
Currently, Google Apps Script doesn't have triggers for Gmail events so the trigger will not invoke every time, the user navigates to a different Gmail conversation. Whenever a new message open it will invoke trigger, contextual trigger. You can also tryout time-driven trigger which invokes after each time interval. To use time-driven trigger open your project on https://script.google.com/. In Apps Script Editor, navigate to Edit -> All your triggers. If there is no trigger then setUp one and Save. See this example Create Time-driven trigger in Gmail-add on
Refer this link for more information How do I detect when I view an email in gmail with google-apps-script script? I think this might be helpful.
I installed a form submit trigger for my project using ScriptApp around the beginning of May. The trigger has worked just fine however I now wish to uninstall the trigger and am running into problems. When I try to view all my current project triggers (Resources > Current project triggers), it returns that there are no associated triggers. Also when I try to run (Resources > All your triggers) it returns that there are no triggers shown.
I'd like to believe that this is the case, that the trigger in question has been somehow deleted but I don't believe that it is. To make sure the trigger didn't run, I de-authorized the script to run from my google account settings.
My suspicions that the trigger was not deleted were confirmed when I received a "Summary of failures for Google Apps Script: Form Processing Script" which told me my script had failed 3 times because, "Authorization is required to perform that action."
These failure e-mails also contain a statement, "To configure the triggers for this script, or change your setting for receiving future failure notifications, click here." When I click on the link, there are no triggers shown...
Here's a look at the code i used to install the trigger:
function formSubmitTriggerInstall() {
var formID = '1rOikLDUAqMWCB0ktjWzFE0oB6LmOHvXuzPAqyq0XLwE';
ScriptApp.newTrigger('processForm')
.forForm(formID)
.onFormSubmit()
.create();
}
I have also tried to locate the trigger using ScriptApp but to no avail.
Does anyone have any suggestions on how I can eliminate this trigger or get the associated trigger ID?
One other note, since I installed the trigger, the google developer's website and documentation went through a major face lift and some of the page content appears to be updated as well. Not sure that would affect my triggers though.
It was confirmed that this was a big and it was fixed by the apps script team.