Versions Compared

Key

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

...

Code Block
global with sharing class MyFormLogic implements B25.Form.Customizer {
    global void customize(B25.Form form) {
        // add our own custom button
        form.addButton(new B25.FormButton('my-custom-button', 'My Button Label'));
        // trigger when the Reservation Type changes
        form.getField(B25__Reservation__c.B25__Reservation_Type__c).onUpdate(new MyReservationTypeHandler());
    }
    global with sharing class MyReservationTypeHandler() extends B25.FormEventHandler {
        global override void handleEvent(B25.FormEvent event, B25.Form form) {
            Id newReservationTypeId = (Id) event.getNewValue();
            B25__Reservation_Type__c reservationType = [SELECT Name FROM B25__Reservation_Type__c WHERE Id = :newReservationTypeId];
            if (reservationType.Name == 'Super Special Type') {
                form.getButton('my-custom-button').hide();
            } else {
                form.getButton('my-custom-button').show();
            }
        }
    }
}

...