[SalesForce] How to read/display the configured columns in Search layout of Account Lookup Dialogs

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 ?

Best Answer

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

Related Topic