Skip to main content

Apex Reference

Constants

These constants should be used when implementing a custom lookup. Do not hardcode their underlying values within your code as they are subject to change without notice.

NameTypeDescription
seven20.Lookup.CONTEXT_RECORD_ID_KEYStringKey used to store the record ID in the context detail map
seven20.Lookup.CONTEXT_SEARCH_TERM_KEYStringKey used to store the search term in the context detail map
seven20.Lookup.RECENTLY_VIEWED_RESULT_LIMITIntegerMaximum number of recently viewed records to return. The value should be integrated into any query ran
seven20.Lookup.SEARCH_RESULT_LIMITIntegerMaximum number of search results to return. The value should be integrated into any query ran
warning

Always include a search result limit, the limits provided by these constants ensure a consistent user experience across lookups and have been chosen to ensure performance and usability.

seven20.Lookup.Context class

Provides the lookup logic with the necessary information to perform the lookup. Any instance of this class, and values returned by its methods, should be considered immutable.

MethodReturn TypeDescription
getQuiddity()StringUnique identifier for the lookup, describing its location within the UI context.
getSObjectTypes()List<Schema.SObjectType>SObject types which the lookup can return
getDetail()Map<String, Object>Gets any detail about the lookup, such as the searchTerm entered by the user. This value should be considered immutable

seven20.Lookup.Querier interface

Defines the methods that must be implemented by a custom lookup class, this is the class that will be invoked by the controller to perform the lookup logic.

MethodReturn TypeDescription
getRecordDetail(seven20.Lookup.Context ctx)seven20.Lookup.ResultReturns the detail of a single record. Called when a lookup has a prefilled value
getRecentlyViewed(seven20.Lookup.Context ctx)List<seven20.Lookup.Result>Returns a list of recently viewed records. Called when a lookup is opened. Sort the results by LastViewedDate in descending order
search(seven20.Lookup.Context ctx)List<seven20.Lookup.Result>Returns a list of search results. Called when a user enters a search term. Results should be sorted by relevance
tip

While this class is the entry point for a lookup query, it doesn't need to contain all its logic. If adjusting query logic by quiddity, it may be beneficial to create a separate class for each quiddity.

seven20.Lookup.Result interface

Defines a result record returned by the lookup querier.

MethodReturn TypeDescription
getId()IdGet the ID of the result record
getIcon()StringGet the icon of the result record. This should be an SLDS icon, e.g. standard:account_info or custom:custom1. Returning a value is optional
getText()StringGet the primary display text for the result, e.g. the record's name
getMetaText()StringGet the secondary display text for the result, e.g. the record's type or a related field value. Returning a value is optional
tip

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 class described below.

seven20.LookupQuerierResult

A generic implementation of the seven20.Lookup.Result interface and should be used for simple result use cases.

It has the following constructor:

global LookupQuerierResult(Id id, String text, String metaText, String icon)
info

The id and text values are required, all others are optional.

seven20.Lookup.QueryException exception

Thrown when an error occurs during the initialisation of the custom seven20.Lookup.Querier class.