function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
DrceteDrcete 

Get Default Search Layout columns for a table via Apex

Hello,

Is it possible to get a table's Default Search Layout Columns programmatically in an apex class?

Thanks!

Best Answer chosen by Drcete
DrceteDrcete

I decided to use the table's SearchLayout settings for lookups.

https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_searchlayouts.htm

All Answers

Abdul KhatriAbdul Khatri
Hi Drcete,
 
I hope this link may help you 
https://trailhead.salesforce.com/content/learn/modules/apex_metadata_api/apex_metadata_api_intro?trailmix_creator_id=strailhead&trailmix_slug=prepare-for-your-salesforce-platform-developer-ii-credential

or you may need to use the following to achieve your need
https://github.com/financialforcedev/apex-mdapi/blob/master/apex-mdapi/src/classes/MetadataService.cls

If you give some specifics of your need that would be great
DrceteDrcete

Thank you Abdul,
I plan to use these columns in an external app, as fields to be queried afterwards for the table.
I will call a Rest endpoint, passing the table name to obtain them.
Example: GetTableDisplayFields('Account')  could return ['Name', 'Account Name'].

DrceteDrcete

I decided to use the table's SearchLayout settings for lookups.

https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_searchlayouts.htm

This was selected as the best answer