Skip to main content
Skip table of contents

Customize the Published Reservations

When publishing a template, actual reservations will be created. These reservations can be customized by implementing an Apex class. This article describes how to do this.

Create an Apex Class

  1. Create a global Apex class that implements the Callable Interface.

  2. Implement the call method inside your class.

  3. The call method is expected to return a B25__Reservation__c which will be the blueprint for the generated reservations.
    More details about this method can be found below in the section ‘Implementing the Call Method’.

  4. Save your class and remember the name for the next section.

Create a Custom Setting

  1. Create a new Custom Setting of type B25__System_Setting__c.

  2. For the setting Name, fill in Template Reservation Prototype Class.

  3. For the String Value, fill in the name of the Apex class that you created in the previous section.

  4. Save the setting. When publishing templates, your class will now be used.

Implementing the Call Method

The call method will be called with the following arguments: call(String action, Map<String, Object> args).

action will have the value 'getPrototypeForTemplate'

args will contain two keys:

  • 'template' will contain the B25__Reservation_Template__c being published

  • 'reservation' will contain a prototype B25__Reservation__c which contains information about the start and end time

The call method is expected to return a B25__Reservation__c which will be the blueprint for the generated reservations.
Tip: you can simply modify the 'reservation' being passed as input, and return it.

Code Example

JAVA
global with sharing class MyCustomPublisher implements System.Callable {
    
    public Object call(String action, Map<String, Object> args) {
                
        // get the template and query additional fields
        B25__Reservation_Template__c template = (B25__Reservation_Template__c) args.get('template');
        template = [
            SELECT B25__Staff__c, B25__Resource__c 
            FROM B25__Reservation_Template__c
            WHERE Id = :template.Id
        ];

	// get the reservation and modify it        
        B25__Reservation__c reservation = (B25__Reservation__c) args.get('reservation');
        reservation.B25__Resource__c = template.B25__Resource__c;
        reservation.B25__Staff__c = template.B25__Staff__c;
        reservation.B25__Title__c = 'This reservation was created by MyCustomPublisher';
        
        return reservation;        
    }
}

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.