...
This section contains some quick examples without much explanation, intended to give you some more ideas of what is possible.
Expand |
---|
title | Add the Account name to all Contact searches |
---|
|
This example adds the Account name to each Contact appearing in the Contact lookup and Contact related list. Code Block |
---|
global class MyFormLogic implements B25.Form.Customizer {
global void customize(B25.Form form) {
form.getLookup(B25__Reservation__c.B25__Contact__c).onSearch(new ContactSearchHandler());
form.getRelatedList(B25__ReservationContact__c.SObjectType).onSearch(new ContactSearchHandler());
}
global class ContactSearchHandler extends B25.SearchHandler {
global override B25.SearchResultCollection getSearchResults(B25.SearchContext searchContext) {
searchContext.setMetaTemplate('{0}', new List<String>{'Account.Name'});
return searchContext.getDefaultResults();
}
}
} |
|
Expand |
---|
title | Immediately add all group members as reservation contacts when selecting a group. |
---|
|
Code Block |
---|
global with sharing class MyFormLogic implements B25.Form.Customizer {
global void customize(B25.Form form) {
// Trigger MyGroupHandler when the Group field changes
form.getField(B25__Reservation__c.B25__Group__c).onUpdate(new MyGroupHandler());
}
global with sharing class MyGroupHandler extends B25.FormEventHandler {
global override void handleEvent(B25.FormEvent event, B25.Form form) {
// Get all members that belong to the group
Id newGroupId = (Id) event.getNewValue();
List<B25__Group_Membership__c> groupMembers = [SELECT B25__Contact__c FROM B25__Group_Membership__c WHERE B25__Group__c = :newGroupId];
// Loop through the members and add the contact to the reservation contacts
for(B25__Group_Membership__c groupMember : groupMembers){
B25__ReservationContact__c reservationContact = new B25__ReservationContact__c();
reservationContact.B25__Contact_Lookup__c = groupMember.B25__Contact__c;
form.getRelatedList(B25__ReservationContact__c.SObjectType).addRecord(reservationContact);
}
//This updates the quantity of the reservation to the amount of contacts in the group
form.getField(B25__Reservation__c.B25__Quantity__c).updateValue(groupMembers.size());
}
}
} |
|
...