Set Up Calendar Integration

Learning Objectives

After completing this unit, you’ll be able to:

  • Enable Event Management.
  • Sync Salesforce calendar with an external one.
  • Set up calendar integration using Apex.

Calendar Integration 

It’s a sunny day in Pennsylvania, and Ryan Dobson, a financial advisor at Cumulus Cloud Bank, is having some quality time with his daughter. They are barbecuing lunch in their backyard. “It’s all about getting the timing right for that perfect steak,” he tells her. Customers routinely consult Ryan for investment opportunities at the bank. As he turns his wrist to check the time, he realizes that he’s got an online appointment with a client in the next 3 minutes!

Although Ryan knew about the appointment, he lost track of time and his phone’s calendar didn’t have the meeting saved. Given the volume of appointments that the bank’s users set up through Salesforce Scheduler, Cumulus Cloud employees (and even customers) want to have the appointments synced to the external calendar apps that they use, such as Microsoft Outlook and Google Calendar.

Ryan’s birthday is also coming up next week, and he wouldn’t want any of his Salesforce Scheduler appointments to conflict with the hours he’s blocked on his personal Outlook calendar to spend time with family. 

Matt’s got to ensure that Salesforce Scheduler can do two things. 

  • “Read” Ryan’s other appointments on Outlook to avoid conflicts between them
  • Write new appointments to his Outlook calendar

There are two ways Matt can set up the calendar integration. 

  1. Get the events on Salesforce Calendar and then sync this calendar with an external one, such as Outlook and Google Calendar. This is the preferred method.
  2. Write an Apex class that reads external calendars and directly writes Salesforce Scheduler events to external calendars. This method requires Salesforce programming expertise and is ideal for customers who want to exercise greater control over the entire process.

Let’s go over both the methods of reading external calendars and writing to them, but remember that you need only choose one of them.

Read External Calendars via Salesforce Calendar and Apex

To connect a Salesforce calendar with an external one such as Microsoft Outlook, Matt uses the Salesforce app Lightning Sync or Einstein Activity Capture. Here’s some important information that Matt shares when he connects users’ calendars.

  • If you use Lightning Sync or Einstein Activity Capture, tell your users which calendar to use to edit events based on the sync direction you set. Check out the Resources section for more information on Lightning Sync and Einstein Activity Capture.
  • When users create appointments in Salesforce Scheduler, they are view-only on the Salesforce calendar. That means that users can only modify or cancel those appointments in Salesforce Scheduler.
  • When you set the sync direction to bidirectional or Salesforce to external calendar, appointments that users create in Salesforce Scheduler appear as events on their external calendar. Users must modify or cancel those appointments in Salesforce Scheduler. If users modify or cancel those events directly on the external calendar, the events can be out of sync with the Salesforce calendar. 

When Matt’s done connecting calendars, he lets users know which calendar to use to edit events, based on the sync direction as follows.

Sync Direction

Expected Behavior

Where to Edit Events?

Salesforce to external calendar


Events created or edited in Salesforce Scheduler appear on the Salesforce calendar and sync to external calendars.


Events created or edited on external calendars don’t appear on or sync to the Salesforce calendar. They aren’t considered when determining the availability of service resources in Salesforce Scheduler.


Salesforce Scheduler


External calendar to Salesforce

Events created or edited on an external calendar appear on and sync to the Salesforce calendar. They are considered when determining the availability of service resources in Salesforce Scheduler.


Events created or edited from Salesforce Scheduler don’t sync to external calendars.


External calendar


Bidirectional

Events created in Salesforce Scheduler appear on the Salesforce calendar and sync to external calendars.


Events created or edited on an external calendar appear on and sync to the Salesforce calendar. They are considered when determining the availability of service resources in Salesforce Scheduler.


Salesforce Scheduler

Here’s an illustration of the flow of data. Exchange refers to an external mail server such as Outlook, which passes on the data to the Salesforce calendar in Salesforce Scheduler via Lightning Sync. When there’s a request or an attempt to book an appointment, Salesforce Scheduler checks the updated calendar data and displays available time slots.

An illustration of the flow of data from an external mail server to Salesforce Scheduler via Lightning Sync.

The other way to read external calendars is by implementing an Apex class that gets information from the external calendar as a synchronous call. Matt works with a developer to implement this. Here’s what they do.

  1. Use the LxScheduler.ServiceResourceScheduleHandler Apex interface to write an Apex class that returns the time slots on the external calendar that are already booked for the requested service resources. Matt and the developer work on an Apex class for Outlook.
  2. Associate the Apex class with Salesforce Scheduler flows or API calls through the External Calendar Event Handler scheduling policy rule.
    1. From Setup, enter Scheduling Policies in the Quick Find box, then select Scheduling Policies.
    2. Click Edit next to Default Appointment Scheduling Policy or your custom scheduling policy.
    3. Click in the Read External System Events field, and select your Apex class.
    4. Click Save.

The Default Appointment Scheduling Policy page showing an Apex class selected.

Here’s an illustration of the flow of data. Exchange refers to an external mail server such as Outlook, which passes on the data to the Salesforce calendar in Salesforce Scheduler via an Apex class. When there’s a request or an attempt to book an appointment, Salesforce Scheduler checks the updated calendar data and displays available time slots.

An illustration of the flow of data from an external mail server to Salesforce Scheduler via Apex class.

Write to External Calendars via the Salesforce Calendar and Apex 

Matt uses the Event Management setting to write Salesforce Scheduler appointments to the Salesforce calendar. 

  1. From Setup, in the Quick Find box, enter Salesforce Scheduler, then select Salesforce Scheduler Settings.
  2. Enable Event Management.

With Event Management enabled, service resources can see their scheduled appointments as events on their Salesforce calendar as well as see any changes that they make to the appointment in Salesforce Scheduler. Any change updates the corresponding event on the Salesforce calendar.

Here’s how it works. When a service appointment gets created, updated, or deleted, it goes to the Salesforce calendar, and then gets passed on to an exchange server such as Outlook via Lightning Sync. 

An illustration of the flow of data from Salesforce Scheduler to the exchange server.

Note

Note

  • To use this feature in an Experience Cloud site, you need the Customer Community Plus or Partner Community license. 
  • Salesforce Scheduler creates a Salesforce calendar event for an appointment only when the appointment has a scheduled start time and an end time.
  • To update the start or end time of an event, update the appointment in Salesforce Scheduler. Don’t edit the event directly on the Salesforce calendar. If you cancel an appointment or update it to remove the scheduled start and end time, the corresponding event is deleted from the Salesforce calendar.
  • Users can book an asset such as a room or equipment and add them to an appointment (the asset does not generate a separate appointment).

Another way to write to external calendars is via an Apex class. This method is recommended if you have a large customer base and want more control.

Matt first enables the External Calendar Update setting to let new appointments or appointment updates trigger platform events.

  1. From Setup, enter Lightning Scheduler in the Quick Find box, then select Lightning Scheduler Settings.
  2. Enable Publish Appointments as Platform Events.

The Lightning Scheduler Settings page showing Publish Appointments as Platform Events enabled.

A platform event is published when a service appointment with an assigned resource is created, a service appointment is deleted, an assigned resource is added or removed, or there are changes to key parameters related to appointments. When a time slot is blocked before or after an appointment, or when an asset service resource is booked, a platform event is not triggered.

Matt teams up with the bank’s in-house developer, Ancelot Mark Pinto, for the next step. Together, they use the Subscribing to Platform Events Developer Guide to subscribe to the AppointmentSchedulingEvent platform event with Apex triggers. 

Note

Note

Depending on the need, you can also use an EMP Connector, a CometD client, or a third-party connector such as the Salesforce Platform Events Source Connector for Confluent Platform.

The last step is to implement APIs to write the platform event changes to the external email server. Since Ryan and most of the bank’s employees use Outlook personally, Matt uses the Microsoft Graph REST API to publish the events to Outlook. 

Here’s an illustration of how it works. When a service appointment gets created, updated, or deleted, it goes to the Salesforce calendar and also triggers a platform event, which then gets published to the external calendar via Apex triggers or CometD.

An illustration of the flow of data from Salesforce Scheduler to an external mail server through platform events.

In the next unit, Matt edits flows.

Resources 

Keep learning for
free!
Sign up for an account to continue.
What’s in it for you?
  • Get personalized recommendations for your career goals
  • Practice your skills with hands-on challenges and quizzes
  • Track and share your progress with employers
  • Connect to mentorship and career opportunities