Versions Compared

Key

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

...

Expand
titleDisplay two contact names linked to the account as meta text on the search result
Code Block
languagejava
global class AccountLookupSearchHandler extends B25.SearchHandler {
    global override B25.SearchResultCollection getSearchResults(B25.SearchContext searchContext) {
        B25.SearchResultCollection collection = new B25.SearchResultCollection();
        for (Account account : [SELECT Id, Name, (SELECT Name FROM Contacts LIMIT 2) FROM Account LIMIT 20]) {
            List<String> metaTextArray = new List<String>();
            for (Contact contact : account.Contacts) {
                metaTextArray.add(contact.Name);
            }
            collection.addSearchResult(new B25.SearchResult(account.Id, account.Name).setMetaText(String.join(metaTextArray, ', ')));
        }
        return collection;
    }
}
Expand
titleIf the status of the reservation is "completed" hide the title field, otherwise show
Code Block
languagejava
global with sharing class MyFormLogic implements B25.Form.Customizer {
    global void customize(B25.Form form) {
        // This is where we will add our handlers to the form
        form.getField(B25__Reservation__c.B25__Status__c).onUpdate(new MyStatusHandler());
    }

    global with sharing class MyStatusHandler extends B25.FormEventHandler {
        global override void handleEvent(B25.FormEvent event, B25.Form form) {
            Id newStatusId = (Id) event.getNewValue();
            B25__Reservation_Status__c status = [
                SELECT Name
                FROM B25__Reservation_Status__c
                WHERE Id = :newStatusId
            ];

            if (status.Name == 'Completed') {
                form.getField(B25__Reservation__c.B25__Title__c).hide();
            } else {
                form.getField(B25__Reservation__c.B25__Title__c).show();
            }
        }
    }
}