forceCalendar/Docs
Salesforce

LWC Integration

Public component properties and methods, snapshots, persistence, and all-day transport.

Public properties

PropertyDefaultPurpose
currentViewmonthmonth, week, day
height800pxCalendar CSS height
recordIdnullRelated-record filtering and creation context
readOnlyfalseDisable UI mutations and LWC save callbacks
<template>
  <c-force-calendar current-view="week" height="700px"
    record-id={recordId} read-only></c-force-calendar>
</template>

Public methods

MethodPurpose
refreshEvents()Refresh the wired Apex result
addEvent(event)Add through the component; blocked when read-only
setView(view)Change the visible view
goToDate(date)Change the visible date and fetch range
const calendar = this.template.querySelector('c-force-calendar');
calendar.setView('week');
calendar.refreshEvents();

Loading and persistence

@wire(ForceCalendarController.getEvents) receives the requested range and record context. Its result is applied with the Interface snapshot API, not a loop of event-create commands. Refresh and navigation therefore do not write the loaded records back to Salesforce.

The LWC loads the combined static resource once, creates forcecal-main inside a manual DOM container, and applies readOnly/the production color-picker setting before use. LWS is required.

Mutation handlers call createCalendarEvent, updateCalendarEvent and deleteEvent. Writes for the same record are serialized. Pending edits are preserved, temporary create IDs are mapped to Salesforce IDs, and failed writes restore confirmed state. Async results are scoped to their connection/range context so a late response does not replace a newer view.

These handlers are integration details, not a second public API for applications to call directly. Listen only once per Interface mutation: legacy/current DOM event names are aliases.

All-day data boundary

Timed events send startDateTime and endDateTime as instants. All-day events instead send startDate and inclusive lastDay as civil dates, with isAllDay: true. A same-day event is valid.

The Apex controller maps those civil dates to Salesforce's native inclusive UTC-midnight representation. The LWC reconstructs local start-of-day/end-of-day for Interface. Do not shift all-day native values through the browser timezone, subtract a day, or use a fixed 24-hour conversion.

Record contexts and recurrence

Contact and Lead context creation uses WhoId; supported other records use WhatId. Apex verifies object and record access and rejects unsupported/inaccessible contexts. A standalone own-calendar listing can omit inaccessible optional relationship fields.

Native recurring events are marked with metadata.forceCalendarRecurring in the Interface, without adding a synthetic RRULE. Their Edit/Delete/drag/resize are disabled, and Apex independently refuses unsupported recurring mutations. Manage series and occurrences in Salesforce Calendar.

Errors and read-only behavior

The component displays errors and supports refresh/retry. Read-only mode blocks built-in editing and the LWC's persistence callbacks/public addEvent; it does not revoke Salesforce permissions or constrain a separate host editor. See permissions for authorization.