Excerpt |
---|
|
Enables developers to create a recurring series of reservations. |
The RecurringReservations class enables Enables developers to create a recurring series of Reservations. The method It only creates Reservations, and does not insert or validate them. To validate the reservations, you can call B25.BulkReservationValidator.validate.
Methods
Panel |
borderColor Expand |
---|
grey | title | generateRecurringReservationSeries(Context context) |
---|
|
DescriptionThis method takes one or more lists of Reservations wrapped in a Context class, and adds any detected soft or hard conflicts to them. Expand |
---|
|
|
panelSignature
Code Block |
---|
language | java |
---|
global static B25.RecurringReservations.Result generateRecurringReservationSeries(B25.RecurringReservations.Context context) |
Parameters
Code Block |
---|
language | java |
---|
B25.RecurringReservations.Context |
An instance of B25.RecurringReservations.Context. This object contains a prototype Reservation (which will be cloned to create each Reservation in the result), a Recurring Reservation record with all the recurrence settings, and some more optional parameters.
Return Type
Code Block |
---|
language | java |
---|
B25.RecurringReservations.Result |
This object contains the resulting series of Reservations.
Inner Classes
Panel |
---|
borderColor | grey Expand |
---|
|
DescriptionThis object contains a prototype Reservation (which will be cloned to create each Reservation in the result), a Recurring Reservation record with all the recurrence settings, and some more optional parameters. Expand |
---|
|
|
Panel |
---|
borderStyle | solid |
---|
title | PropertiesProperties
Code Block |
---|
language | java |
---|
B25__Reservation__c prototype |
This record will be cloned to create each Reservation in the result. The only required fields on this record are B25__StartLocal__c and B25__EndLocal__c, which are used to define at what time of day the resulting Reservations should start and end.
Code Block |
---|
B25__Recurring_Reservation__c recurringReservation |
This record contains the recurrence settings that will define on which dates all the resulting Reservations will occur. For more information about all the fields on this object, see the help texts on the B25__Recurring_Reservation__c object fields in setup. Additionally, you could consider creating a recurring Reservation through
the Booker25 the GoMeddo UI, and then inspect the created B25__Recurring_Reservation__c object's field values.
Code Block |
---|
Set<String> skipUnavailabilityDimensions |
This optional parameter can contain one or more names of dimensions. The creation algorithm will then skip any periods of times that these dimensions are unavailable. For example, if you are creating Reservations for a staff member, and this staff member is on holiday for a week, this week will be skipped.
Panel |
---|
borderColor | grey
Expand |
---|
|
DescriptionThis class wraps the resulting series of B25__Reservation__c objects. Take note that these Reservations have not yet been inserted or validated. Expand |
---|
|
|
panelProperties
Code Block |
---|
language | java |
---|
List<B25__Reservation__c> reservations |
This properties contains the resulting series of Reservations. These Reservations have not yet been inserted or validated. To validate the Reservations, you can call B25.BulkReservationValidator.validate.
Example
...
This example shows how you can use the class in your own code.
Code Block |
---|
B25.RecurringReservations.Context context = new B25.RecurringReservations.Context();
// create a prototype that will be used to create the new reservations
context.prototype = new B25__Reservation__c(
B25__Startlocal__c = System.now(),
B25__EndLocal__c = System.now().addhours(1),
B25__Resource__c = 'xxxxxxxxx', // fill in a Resource Id here (or choose a different dimension, like B25__Staff__c)
B25__Title__c = 'Sample Reservation',
B25__Reservation_Type__c = 'xxxxxxxxxxxxx'); // fill in a Reservation Type Id here
// the following settings will create a series of 7 reservations, starting today
context.recurringReservation = new B25__Recurring_Reservation__c(
B25__Start_date__c = System.today(),
B25__End_date__c = System.today().addDays(100),
B25__Recurrence_Type__c = 'DAILY',
B25__Repeat_Interval__c = 1,
B25__End_Condition__c = 'NUMBER_OF_RESERVATIONS',
B25__Number_Of_Reservations__c = 7);
// skip any periods that the chosen Resource is unavailable
context.skipUnavailabilityDimensions = new Set<String>{'B25__Resource__c'};
// generate the resulting reservations and insert them
B25.RecurringReservations.Result result = B25.RecurringReservations.generateRecurringReservationSeries(context );
system.debug(result.reservations);
insert result.reservations; |