...
For each dimension that a reservation can be related to (through either a lookup or a junction), this class supports two approachesuse cases:
Simple - The exact related record
...
is already known
...
. I.e. the resource lookup has already been populated with the id of room one.
Complex - The
...
related record
...
can be any out of a pool of records. I.e. we have a pool of resources (let’s say all rooms in building one), for which we want to know all the possible time slots
...
.
These use cases can be mixed in a single call to the method. For example the resource is fixed but the staff can be any from a pool of staff members.
Example use cases for lookups
...
Code Block |
---|
B25.TimeSlotFinder.Context context = new B25.TimeSlotFinder.Context(); // the time slot context defines what the resulting series of slots should look like context.timeSlotContext = new B25.TimeSlotGenerator.Context(); context.timeSlotContext.startOfRange = System.now(); context.timeSlotContext.endOfRange = System.now().addHours(2); context.timeSlotContext.duration = 60; context.timeSlotContext.interval = 15; // specify all the potential resource ids // NOTE: replace these with resource ids that exist in your org! context.fieldIds = new Map<String, List<Id>>{ 'B25__Resource__c' => new List<Id>{'a0eJX000000hnL7YAI', 'a0eJX000000hnL8YAI'} }; // call the method and do something with the result B25.TimeSlotFinder.Result result = B25.TimeSlotFinder.findTimeSlots(context); for (B25.TimeSlot timeSlot : result.timeSlots) { System.debug('available time slot from ' + timeSlot.startDatetime + ' until ' + timeSlot.endDatetime); B25.TimeSlotWithReservations timeSlotWithReservations = (B25.TimeSlotWithReservations) timeSlot; System.debug(timeSlotWithReservations.reservations); } |
GoMeddo Rest API
In the GoMeddo Rest API, there is a similar function called /timeSlots that displays available timeslots based on a given reservation.