Skip to main content
Skip table of contents

Pre-populate child reservations based on the parent

This example shows how you can pre-populate fields on child reservations based on the parent reservation from which they are created.

To prepopulate fields you need to add a handler to the onInit event of the form, in your 'customize' method.

CODE
form.onInit(new OnInitHandler());

And then add an inner class named which copies the desired fields (in this case the title) from the parent.

CODE
global class OnInitHandler extends B25.FormEventHandler {
    global override void handleEvent(B25.FormEvent event, B25.Form form) {
        B25.FormRecord newRecord = form.getActiveRecord();
        B25.FormRecord parentRecord = form.getParentRecord();
        Object parentValue = parentRecord.get(B25__Reservation__c.B25__Title__c);
        newRecord.put(B25__Reservation__c.B25__Title__c, parentValue);
    }
}

Full code

CODE
global with sharing class CustomFormLogic implements B25.Form.Customizer {
    
    global void customize(B25.Form form) {
        form.onInit(new OnInitHandler());
    }
	
    global class OnInitHandler extends B25.FormEventHandler {
        global override void handleEvent(B25.FormEvent event, B25.Form form) {
            B25.FormRecord newRecord = form.getActiveRecord();
            B25.FormRecord parentRecord = form.getParentRecord();
            Object parentValue = parentRecord.get(B25__Reservation__c.B25__Title__c);
            newRecord.put(B25__Reservation__c.B25__Title__c, parentValue);
        }
    }
}

JavaScript errors detected

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

If this problem persists, please contact our support.