Newer Version Available

This content describes an older version of this product. View Latest

GetAppointmentSlotsInput Class

Contains information about the available appointment time slots for a resource based on given work type group and territories.

The appointment time slots are determined based on your Salesforce Scheduler data model configurations. Here are some prerequisites that you can consider while setting up data.

  • Set up Salesforce Scheduler before making your requests. The setup includes creating or configuring Service Resources, Service Territory Members, Work Type Groups, Work Types, Work Type Group Members, and Service Territory Work Types. See Set Up Salesforce Scheduler for more information.
  • Configure a work type mapped for each territory in the request body via Service Territory Work Type. Map the same work type to the work type group, via work type group member.

The following factors affect how time slots are calculated and returned.

  • Timezones that differ across operating hours are handled and results are always returned in UTC.
  • The resource must be marked as a required resource on the assigned resource object.
  • The resource is considered unavailable If the status categories of the resource assigned to service appointments are other than Canceled, Cannot Complete, and Completed.
  • Resource Absences of all types are considered unavailable from start to end.
  • The following fields of Work Type records, if configured, are used to fine-tune time slot requirements. For more information, see Create Work Types in Salesforce Scheduler.
    Parameter Description
    Timeframe Start Time slots sooner than current time + Timeframe Start aren’t returned.
    Timeframe End Time slots later than current time + Timeframe End aren’t returned.
    Block Time Before Appointment The time period before the appointment is considered as unavailable.
    Block Time After Appointment The time period after the appointment is considered as unavailable.
    Operating Hours The overlap of all operating hours from the account, work type, service territory, and service territory member are considered while determining time slots. For more information, see Set Up Operating Hours in Salesforce Scheduler.
  • Only the time slots within the period of 31 days from the start date are returned.
  • Salesforce Scheduler uses multiple factors, such as field values, scheduled appointments, absences, Scheduler Settings, and Scheduling Policies to determine available time slots, including the earliest and latest appointment slots. See How Does Salesforce Scheduler Determine Available Time Slots.

    If asset scheduling is enabled, you can provide an asset-based service resource in requiredResourceIds to retrieve available timeslots for the asset resource.

    Note

Namespace

LxScheduler

Usage

The constructor for this class can’t be called directly. Create an instance of this class using the GetAppointmentSlotsInputBuilder.build() method.

This example shows how to get a list of available time slots based on workTypeGroupId:

1//Build input for GetAppointmentSlots API
2   lxscheduler.GetAppointmentSlotsInput input = new lxscheduler.GetAppointmentSlotsInputBuilder()
3      .setWorkTypeGroupId('0VSxx0000004C92GAE')
4      .setTerritoryIds(new List<String>{'0Hhxx0000004C92CAE'})
5      .setStartTime(System.now().format('yyyy-MM-dd\'T\'HH:mm:ssZ'))
6      .setEndTime(System.now().addDays(1).format('yyyy-MM-dd\'T\'HH:mm:ssZ'))
7      .setAccountId('001xx000003GYK0AAO')
8      .setRequiredResourceIds(new List<String>{'0Hnxx0000004C92CAE'})
9      .setSchedulingPolicyId('0Vrxx0000004CAe')
10      .setApiVersion(Double.valueOf('48.0'))
11      .build();
12
13String response = lxscheduler.SchedulerResources.getAppointmentSlots(input);

This example shows how to get a list of available time slots based on workType:

1//Build WorkType
2   lxscheduler.WorkType workType = new lxscheduler.WorkTypeBuilder()
3      .setId('08qxx0000004C92AAE')
4      .build();
5
6   lxscheduler.GetAppointmentSlotsInput input = new lxscheduler.GetAppointmentSlotsInputBuilder()
7      .setWorkType(workType)
8      .setTerritoryIds(new List<String>{'0Hhxx0000004C92CAE'})
9      .setStartTime(System.now().format('yyyy-MM-dd\'T\'HH:mm:ssZ'))
10      .setEndTime(System.now().addDays(1).format('yyyy-MM-dd\'T\'HH:mm:ssZ'))
11      .setAccountId('001xx000003GYK0AAO')
12      .setRequiredResourceIds(new List<String>{'0Hnxx0000004C92CAE'})
13      .setSchedulingPolicyId('0Vrxx0000004CAe')
14      .setApiVersion(Double.valueOf('48.0'))
15      .build();
16
17String response = lxscheduler.SchedulerResources.getAppointmentSlots(input);

This example shows how to get a list of available time slots based on durationInMinutes and without workTypeGroupId or workType fields:

1//Build WorkType
2   lxscheduler.WorkType workType = new lxscheduler.WorkTypeBuilder()
3      .setDurationInMinutes(60)
4      .build();
5
6   lxscheduler.GetAppointmentSlotsInput input = new lxscheduler.GetAppointmentSlotsInputBuilder()
7      .setWorkType(workType)
8      .setTerritoryIds(new List<String>{'0Hhxx0000004C92CAE'})
9      .setRequiredResourceIds(new List<String>{'0Hnxx0000004C92CAE'})
10      .setApiVersion(Double.valueOf('48.0'))
11      .build();
12
13   String response = lxscheduler.SchedulerResources.getAppointmentSlots(input);

This example shows a sample response of a list of available time slots:

1[
2   {
3     "territoryId": "0Hhxx0000004C92CAE",
4     "startTime": "2021-02-10T16:00:00.000+0000",
5     "endTime": "2021-02-10T16:15:00.000+0000",
6     "remainingAppointments": 1
7   },
8   {
9     "territoryId": "0Hhxx0000004C92CAE",
10     "startTime": "2021-02-10T16:15:00.000+0000",
11     "endTime": "2021-02-10T16:30:00.000+0000",
12     "remainingAppointments": 1
13   },
14]