Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Panel


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;


...