Newer Version Available
RecurringAppointmentsManager Class
Represents the result of using the getRecurringAppointmentSlots method to return a pattern of appointments that recur
weekly.
Namespace
Usage
RecurringAppointmentsManager is an Apex class that takes the RecurringPattern class as a required parameter, and returns a list of RecurringSequence appointments that recur weekly.
RecurringAppointmentsManager Methods
RecurringAppointmentsManager includes the following static method.
getRecurringAppointmentsSlots
Signature
static List
getRecurringAppointmentsSlots
Parameters
- ServiceID
- Type: Id
- Required. The service appointment object to be used to book the first appointment
- PolicyID
- Type: Id
- Required. The policy to be used to get the relevant work rules and objectives for the operation
- CalendarOperatingHoursId
- Type: Id
- Required. This will be determine the structure of the slots we will return, for example 09:00-10:00, 10:00-11:00 etc..
- RecurringPattern
- Type: RecurringPattern Class
- Required. This class instance is sent as a parameter that will contain all the details we need from the recurring pattern.
- SchedulingOptionsCount
- Type: Integer
- Required. How many scheduling options to return at the final answer (top 3 best options for example).
Return Value
Type: List RecurringSequence
Usage
This method returns a list of recurring appointments to repeat daily, weekly, or monthly.
Examples
These examples retrieve a list of recurring appointments. The first uses a method and the second uses a script.
Example 1:
1//Using a method (example):
2public callRecurringVisitsAPI(Id serviceID, Id policyID, Id calendarOperatingHoursId, Integer SchedulingOptionsCount) {
3
4//Fill the pattern object
5RecurringPattern pattern = new FSL.RecurringPattern();
6pattern.DaysOfWeek = new Set<RecurringPattern.DaysOfWeek>{RecurringPattern.DaysOfWeek.Sunday, RecurringPattern.DaysOfWeek.Wednesday};
7pattern.FrequencyType = RecurringPattern.FrequencyType.WEEKLY;
8pattern.Frequency = 3;
9pattern.NumberOfVisits = 10;
10
11//Call the API
12FSL.RecurringAppointmentSlots result = RecurringAppointmentsManager.getRecurringAppointmentsSlots(serviceID, policyID, calendarOperatingHoursId, SchedulingOptionsCount, pattern);
13}
14
15}Example 2:
1//Using a script:
2
3//Fill the pattern object
4FSLMPDEV.RecurringPattern pattern = new FSL.RecurringPattern();
5pattern.DaysOfWeek = new Set<FSL.RecurringPattern.DaysOfWeek>{FSL.RecurringPattern.DaysOfWeek.Tuesday, FSL.RecurringPattern.DaysOfWeek.Wednesday, FSL.RecurringPattern.DaysOfWeek.Thursday};
6pattern.FrequencyType = FSL.RecurringPattern.FrequencyType.WEEKLY;
7pattern.Frequency = 2;
8pattern.NumberOfVisits = 12;
9
10//parameters init
11Id policyID = 'a1Lx00000004PoVEAU';
12Id serviceId = '08px000000OE11dAAD';
13Id operatingHoursId = '0OHx0000000D5IiGAK';
14Integer scheduleOptionsCount = 3;
15
16//Call the API
17FSL.RecurringAppointmentSlots result = FSL.RecurringAppointmentsManager.getRecurringAppointmentsSlots(serviceId , policyID, operatingHoursId, scheduleOptionsCount , pattern);
18
19//Handle the response of the API (example only)
20for (Integer i=1 ; i<= result.recurringSequences.size() ; i++){
21 System.debug('Sequence number: ' + i);
22 System.debug('participatingResources details: /n' + result);
23 System.debug('visitSchedulingOptions details: /n' + result);
24 System.debug('averageObjectivesGrades details: /n' + result);
25 System.debug('sequenceScore details: /n' + result);
26 System.debug('firstPatternOccurrence details: /n' + result);
27}