addEvent(event, options)

Adds an event to the device’s calendar.

Syntax 

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

Parameters 

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

Returns 

A Promise object that resolves as a coerced version of the Event parameter. If an error is encountered, an error message is returned.

Usage 

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

1myCalendarService
2  .addEvent(event, options)
3  .then((results) => {
4    this.addedEvent = results;
5  })
6  .catch((error) => {
7    console.error("Error code: " + error.code);
8    +console.error("Error message: " + error.message);
9  });

For more information on when and why CalendarService coerces (changes) event data, see Implicit Data Coercion.

See Also