4

Trying to build an addon for Google Calendar. When I first click on an event it triggers the eventOpenTrigger function. This works as expected.

If I click on another event again eventOpenTrigger triggers. If I then again click on the original event then eventOpenTrigger is not fired. Is this by design? Seems like this only triggers once for each unique event. I would like to update some information in the card every time the event is clicked on.

Rubén
  • 34,714
  • 9
  • 70
  • 166
Skiltz
  • 544
  • 1
  • 6
  • 18
  • Could you please provide the code you're working on? – Iamblichus Jul 13 '20 at 12:59
  • I'm also struggling with this. Did you able to resolve it somehow? – littleorc Jan 27 '21 at 22:41
  • I am also seeing this issue. It seems like the trigger is connected to the rendering of the pop-up you see when you click on the event, and this pop-up is cached. The event will re-trigger if the browser is refreshed, and the event clicked on, but then it won't fire again until the browser is refreshed. – Gus Feb 06 '21 at 21:48
  • can be demonstrated with `"calendar": { "eventOpenTrigger": { "runFunction": "onCalendarEventOpen" } } ` and `function onCalendarEventOpen(e) { console.log( "foo"); return buildCard(e) }` "foo" only shows once no matter how many times the event is clicked or edited. – Gus Feb 06 '21 at 21:53
  • @lamblichus also FWIW Google Chrome Version 88.0.4324.96 (Official Build) (x86_64) – Gus Feb 06 '21 at 21:58

1 Answers1

0

unfortunately there is no refresh from code, the action is bound to "eventOpenTrigger" when the calendar event is opened, if you want to re-run the function onCalendarEventOpen(event) you need to create an action such as

 var action = CardService.newAction()
                    .setFunctionName('onCalendarEventOpen')
                    .setLoadIndicator(CardService.LoadIndicator.SPINNER)

you can provide a refresh button and add this action to button click, only this way i was able to get the event data that is required, if you do not want any event data and just need to call this function you can return onCalendarEventOpen from another and use calendar api to fetch the event details

 const eventFromAPI = Calendar.Events.get(calendarId, eventId);

this is the only work-around i have been following