NB: The setup below is required before the “New Trip” & “New Expense” Buttons can work correctly on your Custom Object pages.
The Business Purpose universal lookup component works out-of-the-box for Account, Campaign, Case, Contact, Opportunity and Trip. It can be configured to work with any object that can be related to the Trip or Expense objects in these simple steps:
- Create a lookup field on each of the Trip, Flight, Expense and Allocation objects to the object you want to be searchable from the Business Purpose field. All Lookup fields must have the same name. If the business purpose is not valid for Trips and Flights then this can be skipped.
- Create a new SalesTrip Lookup Configuration similar to those already created for the objects configured out-of-the-box. Do this by clicking Setup > type “Custom Metadata” in the quick search > click Custom Metadata Types > click “Manage Records” alongside “Lookup Configuration”
- Click “New” and fill in the following fields: (Skip if you do not want to configure Trips)
- Name: “Expense Business Purpose [Object Name]”
- Configuration Type of "Expense Business Reason"
- Target Object: Expense
- Target Field: the field you created in step 1 above
- Subtitle: the API name of any fields from the parent object that you want to show in the search results. Separate multiple values with commas
- Order: priority to show object records of this type in the search results
- Click Save
- Repeat 3&4 for Trips and Flights as appropriate, substituting references to "Expense" above.
The record names that begin with “Expense Business Reason” and “Trip Business Reason” are examples of how to setup the Universal Lookup to work with either Expenses or Trips. You may also disable the out-of-the-box configurations if you do not want users to be able to search our default objects.
NB: In order for a Flight search to have a business purpose defaulted from the parent Trip, Lookup Configurations for both objects must be configured, and fields created. In order for an Expense to have the Business Purpose populated correctly when created from a Flight, the Lookup Configuration for the Expense must be configured, and fields created on both Expense and Allocation.
NB: If you configure business purpose lookups for more than 5 objects, then only results from the first 5 objects will be shown in the UI. The "first 5" is defined by sorting (asc) the numbers in the salestrip_Order_c field, if any overlap the result is undefined. If the first 5 objects have no matches and the 6th does have matches these will still not be returned.
Workaround:
Deactivate unneeded objects from the custom metadata.
Re-order the objects.
Restrict users access to some objects (if the user doesn't have access these are dropped from the search).