Posts

From Chris Albanese: Scheduler – Book multiple appointments using Flow and the LxScheduler namespace

Introduction

Salesforce Scheduler provides a precision scheduling experience, powered by flow that allows your prospective customers, customers, and employees to schedule appointments with ease and allows you to build stronger relationships with your customers.

Often times, a customer would like to schedule or is required to schedule more than 1 appointment. For example, in one scheduling session, a customer might want to schedule an initial consultation and a follow up appointment 2 weeks later – in other words, schedule the 2 appointments together.

The .gif above depicts scheduling 2 appointments during 1 scheduling session using the customized flow described in this document

Current Situation / Challenge

Product Capability

Scheduler only schedules 1 appointment at a time. Your customer might schedule the first appointment only to find out that the second appointment is not available. Or they might forget to schedule the second appointment.

Complexity of Custom Development

The good news is that Salesforce Scheduler has a robust API available, allowing customers to create their own scheduling experiences to meet their needs. The not so good news in this is that if you use the API to find available appointments, you need to build your own screen to display those to the user. In other words, the Time Slot Selection screen that comes with Scheduler cannot be customized.

The screen above cannot be customized. For example, you cannot allow a user to select 2 time slots.

A Lower Complexity Custom Solution

You can build a custom scheduling solution which can provide options to select two timeslots by leveraging a few things which are mentioned below.

And this solution really has a basic UI. In its current form it is best suited for an internal user. For external use, you should extend the solution to provide more natural calendar controls (like the out of the box timeslot selection component that Scheduler provides). That, of course, will require more complexity, but certainly worth if to deliver a superior user experience.

Scheduler LX namespace / Apex Methods

Use the Scheduler LX namespace to easily get available time slots. For example, call the GetAppointmentCandidates method to get 2 lists of available times slots. Create an @invocableMethod that will allow you to call this from a Flow.

Flow Datagrid Pack

Use this package to display the available time slots from the API call and allow the user to select these. This package can be found on the appexchange. https://appexchange.salesforce.com/listingDetail?listingId=a0N3A00000GAZr7UAH

Flow

Use the power and flexibility of Flow to connect both of these together as well as leverage existing Scheduler flow screen components such as Select Territory to create a custom scheduling experience.

Installation / Technical Details

Using the above mentioned custom options, here is a version of the custom solution that we built to attain the experience we discussed.

You can Install this package in your sandbox and check it out for yourselves. Use it to jump start your own custom scheduling solution for booking more than 1 appointment at the same time.

Create an Account Action (or Opportunity, Lead or Case) to launch the flow called LX Book 2 Appointments that is included in this package. Package link: https://login.salesforce.com/packaging/installPackage.apexp?p0=04t4x000000NXkl&isdtp=p1

Github Repository (does not include Flow Datagrid Pack): https://github.com/cxalbanese/LX-Multi-Appointments

Components

AppExchange Package

  • Flow Datagrid Pack – this solution uses the DataGrid Pack – Tiles screen component to provide a user interface for selecting a time slot. The package link above contains the Tiles component already and does not need to be installed from the appexchange.

Apex Classes

  • LXGetSlots – a class with an @invocableMethod. This class calls the getAppointmentCandidates API to fetch available time slots. This class will format the results so they can be rendered in the DataGrid Pack – Tiles component.
  • schedulerCandidates – represents a time slot returned from the API
  • LXGetSlotsTest, TestUtility – Test class and test class helper

Flows

  • LX Book 2 Appointments – this flow is set up to allow booking of 2 appointments
  • LX Get Slots Helper Flow – this flow is called by LX Book 2 Appointments. It calls the LXGetSlots apex class to get time slots
  • LX Service Appointment Helper flow – this flow is called by LX Book 2 Appointments. Its purpose is to create a service appointment for a selected time slot. It uses the Scheduler Save action and it has a formula field to construct the JSON needed for the Save action

LX Book 2 Appointments flow – calling the API

LX Book 2 Appointments flow – creating 2 appointments

Customize it!

If you want to book 3 or more appointments instead of 2, add additional steps to the LX Book 2 Appointments Flow.

  • Any variable that ends with a ‘2’ should be replicated and end with a ‘3’
  • Formula fields that you replicate should also have 2’s replaced with 3’s
  • Replicate the pattern you see in the flow to find slots for the 3rd appointment
  • Add a Datagrid Pack – Tiles screen component for the 3rd appointment to the Select Slots screen
  • Replicate the pattern you see in the flow for the saving of the appointment

  • Replicate the LX Get Slots Helper Flow 2 step. Note the pattern to determine if slots were found and replicate those
  • Replicate the LX Service Appointment Helper Flow 2 step and related steps. Note the pattern to determine if slots were found and replicate those
  • When replicating a step, make sure to update any input/output variables from ‘2’ to ‘3’.
  • Add Datagrid Pack – Tiles component for the 3rd appointment, make sure to update any input/output variables from ‘2’ to ‘3’.