Deleting an event from the calendar

I have a calendar on my app and use google sheets to keep the calendar data. I created a query to delete a row when a user selects an event on the calendar. When I run the query by itself, it deletes the proper event that was clicked on, but when I add it to the "On Event Delete", in the calendars properties, it does nothing.

Is there a step I am missing or am I not adding my query correctly?

Hi @djbeto2209, Can you share some screenshots of how you've configured this query to run when the event is deleted? Specifically, it would be helpful to see how you're identifying the row to be deleted when the calendar event is deleted.

I am using the "Delete a single row from spreadsheet" action:

If I click on an event and then manually trigger this event, it works properly.

I have also added the query to the "On event delete" section of the calendar.

Screen Shot 2022-04-18 at 9.49.27 AM

Hi @djbeto2209, Unfortunately, it doesn't look like our calendar component supports this functionality :slightly_frowning_face: The calendarMain.selectedEvent property gets cleared before the query runs. I'll go ahead and pass along a report of this issue to our engineering team and add your contact info there. I'll let you know if and when we're able to improve this behavior.

For now, I would suggest you use a temporary state variable to store the id for use in the Google Sheets query. Every time an event is selected, you could set the id of that event in the temp state variable. You could then reference the id set in the temp state in your Google Sheets query triggered on event delete. And on success of the Google Sheets query, you could clear the id from the temporary state variable.

Could that work for your use case for now?

Thank you for the response. I just created a delete button that runs the query for the meantime.

Hi @djbeto2209, Reaching out here to let you know that this bug has been fixed with the updated Calendar Component which we expect to ship to cloud next Tuesday :smile: If you subscribe to our updates, you can get notified when this goes live.

Hi everett_smith there is a way to delete an event from the calendar.

If I select them and press the KEY "Delete" nothing happens I also tried with a script?
Ex.[0].remove() or calendar1.selectedEvent.remove() but the method does not exist.

Unfortunately i haven't figured out how to remove events from the calendar.

Can you help me ?
Tank you

Hi @Daniele_Gregorini, To configure deletion, you'll need to create an event handler on the Calendar for the Remove event that deletes the event in the dataset that's backing the calendar component. How you configure the query that actually performs the delete depends on where and how the the calendar event data is stored. In the query that performs the deletion, you can reference the event to be deleted with calendar1.selectedEvent.eventId. With this event handler set up, clicking an event and pressing the delete key will fire that event. Does that answer your question?

Now everything is much clearer thanks.
I store the data in a "temporary state" and I can delete the calendar events with the "splice", it doesn't delete what I want but I'm working on it. :sweat_smile:


Thanks again for your quick support.

Sweet—happy to have helped :blush: