Defining Custom Logic
Custom logic is defined through the use of a custom Apex class which implements the seven20.Lookup.Querier interface. This class is responsible for performing the logic to return the results of a lookup, and is invoked by the Seven20 system when a lookup is accessed.
There are three methods which the interface provides:
getRecordDetail(seven20.Lookup.Context ctx): Returns the detail of a single record. Called when a lookup has a prefilled valuegetRecentlyViewed(seven20.Lookup.Context ctx): Returns a list of recently viewed records. Called when a lookup is loaded, and the results are displayed when it is opened by a user, but they haven't started typingsearch(seven20.Lookup.Context ctx): Returns a list of search results. Called when a user enters a search term
Ensure classes which implement any Seven20 interface, and any methods within that interface, are defined as global.
Lookup context
Each one of these methods takes in a seven20.Lookup.Context object, which provides the necessary information to perform the lookup. This object contains methods for accessing context on what the user is doing, and whereabouts in the UI they are performing the lookup. This utilises the concept of quiddity, which is the unique identifier for the lookup, describing its location within the UI context. By reading the quiddity value, it is possible to define location-specific logic for the lookup, instead of just a generic implementation.
Returning results
Results are defined using the seven20.Lookup.Result interface. The methods within this interface are used to define the results of the lookup, and should be used to return the results of the query.
Only use the interface when implementing more complex logic in your results (e.g. conditional icons). For simple use cases, or if you're unsure, use the seven20.LookupQuerierResult described in the reference section.
Defining the metadata record
Once the Apex class has been created, the system needs to be instructed on what class to initialise to fulfil an end user's query. This is managed via a set of Seven20 Configuration Metadata records, one for each SObject. Simply update the value of the appropriate record to the name of the new querier class. See Supported Objects for the SObject names and their corresponding metadata record names.
Ensure the name of the class is correct - if the class cannot be initialised an exception will be thrown and users will be unable to use the lookup.
Boilerplate Apex
global with sharing class ExampleLookupControllerQuerier implements seven20.Lookup.Querier {
global seven20.Lookup.Result getRecordDetail(seven20.Lookup.Context ctx) {
// Perform the logic to get the record detail
}
global List<seven20.Lookup.Result> getRecentlyViewed(seven20.Lookup.Context ctx) {
// Perform the logic to get the recently viewed records
}
global List<seven20.Lookup.Result> search(seven20.Lookup.Context ctx) {
// Perform the logic to search for records
}
}