Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Current »

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

form.onInit(new OnInitHandler());

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

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

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);
        }
    }
}

  • No labels