removeEvent(event, options)

Removes an event from a device’s calendar.

Using removeEvent() is an inherently dangerous action, as it allows event data to be irreversibly deleted. Use caution when using this functionality in your component. At an absolute minimum, consider adding a confirmation window for your users that clearly states the outcome of the action, with an option for them to cancel if they wish.

Note

Syntax 

1import { getCalendarService } from 'lightning/mobileCapabilities';
2removeEvent(event: Event,
3  options: CalendarServiceOptions
4  ): Promise<Object>

Parameters 

  • event—(Required) The Event object to be removed from the device’s calendar.
  • options—(Required) A CalendarServiceOptions object to configure the CalendarService request.

Returns 

If successful, nothing is returned. If unsuccessful, an error message is returned.

Usage 

Use this function to remove an event from a device’s calendar.

1myCalendarService
2  .removeEvent(event, options)
3  .then((results) => {
4    console.log("Event successfully removed!");
5  })
6  .catch((error) => {
7    console.error("Error code: " + error.code);
8    +console.error("Error message: " + error.message);
9  });