1

Account Lookup Dialogs - Search Layout Configuration

Salesforce allows each org to configure the columns to be displayed whenever user clicks on Account lookup component.

This can be configured by navigating to

Settings -> Build -> Accounts -> Search Layouts -> Account Lookup Dialogs

and there appears a multi-select picklist where Administrator can add or remove columns of Account object.

Intention behind Configuring Search Layout

I am assuming Administrator would add only key columns from the Account object to the Lookup Dialog Layout which would help the user to decide whether he is picking the right Account at first glance.

My current Salesforce App

I am building a Custom Application where I display some information of Account objects in apex:dataTable. Currently the list of Columns displayed for Accounts are hard coded.

They are:

  1. Account Name
  2. Owner
  3. Account Site
  4. Type
  5. Industry

Requirements for my Salesforce App

  • Each customer have their own custom field on Account which helps them to uniquely narrow down to a particular Account.
  • So I don't want to hard code these fields, but to display the list of fields configured in Search Layouts of Account Lookup Dialogs.

Problem

Now coming to the problem, I tried many ways to reuse the existing Salesforce configuration but couldn't find one.

  1. Approach 1 - find a component which displays the List of Account in UI with a given Lookup Layout
  2. Approach 2 - find someway to read the org settings
$OrgSettings.Account.SearchLayouts.LookupDialogs.ConfiguredColumns ??
  1. Approach 3 - Give a custom page in my App to configure Account object columns and read the config when displaying the dataTable.

Currently I am proceeding with Approach 3 but I find it redundant and hard to keep my custom config and Search Layout config in Sync.

Is there any better approach to achieve the same ?

1

Yes, if you can issue an http get request to

/services/data/v34.0/search/layout?q=object name

You can get the search layout fields.

enter image description here

0

Approach 4 - Call the Metadata API to get the column names in the Search Layout. This blog post by andyinthecloud.com explains how and provides link to github source.

0

An alternate approach can be to create a fieldset and have users configure fields required in your custom screen. This will additionally help them to ensure that they can have different set of fields in search layout and different within your app screens (if they at all need it).

A fieldset is a list of fields of an object (including related object fields) which can be created for standard/ custom objects. Hence, it helps in logically grouping fields and use them in various code/ screens without hardcoding fields in there. For more details on fieldset refer :- https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_dynamic_vf_field_sets.htm

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.