TimeSlotFinder

Finds available time slots for a given reservation.

For each dimension that a reservation can be related to (through either a lookup or a junction), this class supports two use 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

Simple use case

The reservation I want to make has to be in room one, with staff Alex. I pass this reservation to the method, with the resource and staff lookups populated. The method result gives me a simple list of time slots when both the room and the staff are available.

Complex use case

The reservation I want to make has to be in building one (so in any of the rooms there), with any of the staff that work at building one. I pass the reservation to the method, without the resource and staff lookups populated. I separately pass the allowed room ids and staff ids. The method result gives me a more complex list of time slots, each with all the possible room and staff combinations available at that time.

We have some handy utilities for finding the ids to pass to this method!

To get all the room ids in a specific building, use the https://gomeddo.atlassian.net/wiki/spaces/BPD/pages/3586457603 global class.

To get all the staff that work in building one (defined through availability records), use the https://gomeddo.atlassian.net/wiki/spaces/BPD/pages/3586785284 global class.

Example use cases for junctions

Simple use case

The reservation I want to make has to have two reservation contacts: John and Alex. I pass this reservation to the method, with two reservation contact records (one for John, one for Alex) in the separate junctions property. The method result gives me a simple list of time slots when both John and Alex are available.

Complex use case

The reservation I want to make has to have two participants (reservation contacts) out of five possible participants. I pass five reservation contact records (one for each possible participant) in the junctions property. In the requestedNumberOfJunctions property, I specify that I need two reservation contacts to be available. The method result gives me a complex list of time slots, each with all the possible combinations of participants available at that time.

Methods

Description

This method returns the times that a given reservation (optionally with junctions) is possible.

Signature

global static B25.TimeSlotFinder.Result findTimeSlots(B25.TimeSlotFinder.Context)

Parameters

B25.TimeSlotFinder.Context

Contains the reservation, its junctions, and a definition of what the resulting series of time slots should look like (such as slot duration and interval ).

Return Type

B25.TimeSlotFinder.Result

Contains a List<B25.TimeSlot> timeSlots property with the available time slots.

Description

Bulkified version of findTimeSlots. At the time of writing, this method is for convenience only and does not do anything more efficient than calling the unbulkified method multiple times.

Signature

Parameters

A list of request contexts.

Return Type

A list of results.

Inner Classes

Description

This class wraps the request context.

Properties

Contains the definition of what the resulting series of slots should look like, such as the date range, slot duration and slot interval. For more details see https://gomeddo.atlassian.net/wiki/spaces/BPD/pages/3477766153

The reservation to find available time slots for. Make sure all fields that can influence conflict checking are populated. If you are applying the simple use case for lookups (explained here), make sure any lookups to dimensions (resource/staff/etc) that need to be available are populated. Start and end times are not necessary and will be ignored.

Optional. If you are applying the complex use case for lookups, populate this with the possible ids mapped by the api name of the corresponding lookup field.

Optional. If you need any junctions to be available, add them here mapped by relationship name. Applies to both the simple and the complex use case.

Optional. If you are applying the complex use case for junctions, populate this with the required numbers of available junctions, mapped by relationship name.

Description

This class wraps the result, which contains a list of available time slots.

Properties

The time slots when the given reservation (and junctions) are available. Each time slot has a startDateTime and endDateTime.

If you are applying the complex use case for at least one lookup or junction, this property will contain additional data. Each B25.TimeSlot entry in this list will be castable to B25.TimeSlotWithReservations, which have an additional property:

This property will contain all the reservations that are possible during that time slot. The B25.Reservation data type is a wrapper around a reservation and its child records. It has the following properties:

The actual reservation record.

The child records of the reservation (mapped by relationship name). When applying the complex use case for junctions, this will contain the available junctions at the given time slot.

Example

Simple use case

This example shows the simple use case (both for lookups and junctions).

Complex use case

This example shows the complex use case for lookups: