getEvents(startDateSecondsUTC, endDateSecondsUTC, calendars?, options)

Returns all events of all available calendar events in a specified date range from the specified calendars.

Syntax 

1import { getCalendarService } from 'lightning/mobileCapabilities';
2getEvents(
3  startDateSecondsUTC: number,
4  endDateSecondsUTC: number,
5  calendars?: string[],
6  options: CalendarServiceOptions
7  ): Promise<Object>

Parameters 

  • startDateSecondsUTC—(Required) The start of the date range.
  • endDateSecondsUTC—(Required) The end of the date range.
  • options—(Required) A CalendarServiceOptions object to configure the CalendarService request.
  • calendars— The titles of calendars to get events from. If not provided, or null is passed in, events are fetched from all available calendars.

Returns 

A Promise object that resolves as an array of Calendar objects. If an error is encountered, the array is empty.

Usage 

Use this function to fetch all available events in a specified date range from specified calendars.

1myCalendarService
2  .getEvents(options)
3  .then((results) => {
4    this.events = results;
5  })
6  .catch((error) => {
7    this.events = [];
8    console.error("Error code: " + error.code);
9    +console.error("Error message: " + error.message);
10  });
  • If the calendars property is null, events are fetched from all available calendars.
  • If an error occurs, the error is returned via a rejected promise. Handle errors in a catch clause.

Release Preview

This release is in preview. Features described here don't become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can't guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.