GetAppointmentCandidatesInput Class
Set up Salesforce Scheduler before making requests. This 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.
The appointment time slots are determined based on multiple factors, such as field values, scheduled appointments, absences, Scheduler Settings, and Scheduling Policies to determine available time slots. See How Salesforce Scheduler Determines Available Time Slots for more information.
The following factors are considered for returning start time and end time of resources.
- Resource Availability
- Determined using service territory member, service territory, work type, and account operating hours fields.
- Resource Unavailability
- Determined by resource absences, existing appointments that the resource is assigned to. The resource must be marked as a required resource for the appointment with a status that isn’t in closed, canceled, or completed.
- Appointment Start Time Interval in the Scheduling Policy
- Appointment start time interval field in the Scheduling Policy is used to determine when the appointment can start. This interval can be 5, 10, 15, 20, 30, or 60. By default, it’s set to 15.
- Work Type Duration
- The end time is calculated as start time + duration of the work type.
Namespace
Usage
The constructor for this class can’t be called directly. Create an instance of this class using the GetAppointmentCandidatesInputBuilder.build() method.
This example shows how to get a list of available appointment candidates based on workTypeGroupId:
1//Build input for GetAppointmentCandidates API
2 lxscheduler.GetAppointmentCandidatesInput input = new lxscheduler.GetAppointmentCandidatesInputBuilder()
3 .setWorkTypeGroupId('0VSRM0000000ABc4AM')
4 .setTerritoryIds(new List<String>{'0HhRM0000000FXd0AM'})
5 .setStartTime(System.now().format('yyyy-MM-dd\'T\'HH:mm:ssZ','America/New_York'))
6 .setEndTime(System.now().addDays(5).format('yyyy-MM-dd\'T\'HH:mm:ssZ','America/New_York'))
7 .setAccountId('001RM0000053iQgYAI')
8 .setSchedulingPolicyId('0VrRM00000000Bx')
9 .setApiVersion(Double.valueOf('50.0'))
10 .build();
11
12 String response = lxscheduler.SchedulerResources.getAppointmentCandidates(input);This example shows how to get a list of available appointment candidates based on workType:
1//Build WorkType
2 lxscheduler.WorkType workType = new lxscheduler.WorkTypeBuilder()
3 .setId('08qRM0000000G9RYAU')
4 .build();
5
6 lxscheduler.GetAppointmentCandidatesInput input = new lxscheduler.GetAppointmentCandidatesInputBuilder()
7 .setWorkType(workType)
8 .setTerritoryIds(new List<String>{'0HhRM0000000FXd0AM'})
9 .setStartTime(System.now().format('yyyy-MM-dd\'T\'HH:mm:ssZ','America/New_York'))
10 .setEndTime(System.now().addDays(5).format('yyyy-MM-dd\'T\'HH:mm:ssZ','America/New_York'))
11 .setAccountId('001RM0000053iQgYAI')
12 .setSchedulingPolicyId('0VrRM00000000Bx')
13 .setApiVersion(Double.valueOf('50.0'))
14 .build();
15
16 String response = lxscheduler.SchedulerResources.getAppointmentCandidates(input);This example shows how to get a list of available candidate appointments based on durationInMinutes and without the workTypeGroupId or workType fields:
1//Build SkillRequirement
2 lxscheduler.SkillRequirement skillReq = new lxscheduler.SkillRequirementBuilder()
3 .setSkillId('0C5RM0000004EZS0A2')
4 .setSkillLevel(90)
5 .build();
6
7//Build WorkType
8 lxscheduler.WorkType workType = new lxscheduler.WorkTypeBuilder()
9 .setDurationInMinutes(15)
10 .setBlockTimeBeforeAppointmentInMinutes(5)
11 .setBlockTimeAfterAppointmentInMinutes(5)
12 .setTimeFrameStartInMinutes(10080)
13 .setTimeFrameEndInMinutes(40320)
14 .setOperatingHoursId('0OHRM0000000FmG4AU')
15 .setSkillRequirements(new List<lxscheduler.SkillRequirement>{skillReq})
16 .build();
17
18 lxscheduler.GetAppointmentCandidatesInput input = new lxscheduler.GetAppointmentCandidatesInputBuilder()
19 .setWorkType(workType)
20 .setTerritoryIds(new List<String>{'0HhRM0000000FXd0AM'})
21 .setSchedulingPolicyId('0VrRM00000000Bx')
22 .setApiVersion(Double.valueOf('50.0'))
23 .build();
24
25 String response = lxscheduler.SchedulerResources.getAppointmentCandidates(input);This example shows a sample response of a list of available candidates:
1[
2 {
3 "startTime": "2021-02-16T16:15:00.000+0000",
4 "endTime": "2021-02-16T16:16:00.000+0000",
5 "resources": [
6 "0Hnxx0000004C9BCAU"
7 ],
8 "territoryId": "0Hhxx0000004C92CAE"
9 },
10 {
11 "startTime": "2021-02-16T16:30:00.000+0000",
12 "endTime": "2021-02-16T16:31:00.000+0000",
13 "resources": [
14 "0Hnxx0000004C9BCAU"
15 ],
16 "territoryId": "0Hhxx0000004C92CAE"
17 },
18]