Our Workspace Add-on uses an installable calendar event trigger.
The trigger is fired whenever there is a calendar update event.
ScriptApp.newTrigger('calendarTrigger').forUserCalendar(calendarId).onEventUpdated().create();
This works fine until we deploy a new version of our add-on.
Once deployed the installable trigger remains but tied to a previous deployment version.
Any calendar events are ignored and the trigger sits there doing nothing.
We can code our add-on to remove the trigger and re-add it but this requires our add-on to be opened by a user.
ScriptApp.deleteTrigger(tr);
ScriptApp.newTrigger('calendarTrigger').forUserCalendar(calendarId).onEventUpdated().create();
The problem is that calendar events are ignored until this manual intervention (which may not occur for some period of time).
How are we supposed to have the trigger update when we deploy a new version of our app?
CodePudding user response:
Make sure that with each new deployment, you update the Workspace Addon in the GCP Platform, to do that:
- Access GCP
- Marketplace > Google Marketplace SDK > App Configuration
- In the Deploy using Apps Script Deployment Id (first item) update the Deployment Id.
The Deployment Id is found in the Apps Script Project > Deploy (blue button, top right) > Manage Deployments > Pick the active one (on the left) and its Deployment ID is displayed.
Also note that it is helpful that if you create a new version of your script, then I suggest you when you deploy, click on the current version, then on the pen (up top) then "Add new Version". This way there is one deployment with a new version, as opposed to having multiple deployments with various versions active.
CodePudding user response:
Issue:
The same behavior was reported in Issue Tracker some time ago, albeit in this case referring to time-driven triggers:
This seems to happen to all triggers installed via Workspace add-on: once a Workspace add-on is updated with a new deployment, the triggers attached to older deployments stop executing.
Workaround:
While at this point it's not clear whether this is expected behavior or not, a possible workaround (as explained by Neven Subotic) for updating a Workspace add-on without disabling the current deployment triggers is to edit a versioned deployment instead of creating a new one.