0

Is there a way to get API Names of fields through Apex, which are displayed in the list view? I tried using Metadata API, Rest API, User Interface API, LDS.

0

List views are part of the CustomObject metadata type since they're associated with specific object configurations. The list view columns will have the API names of the fields displayed. Here's an example of a list view on a Lead.object metadata file:

<listViews>
    <fullName>AllLeads</fullName>
    <columns>FULL_NAME</columns>
    <columns>LEAD_SCORE</columns>
    <columns>LEAD.TITLE</columns>
    <columns>LEAD.COMPANY</columns>
    <columns>LEAD.EMAIL</columns>
    <columns>LEAD.PHONE</columns>
    <columns>Lead_Quality__c</columns>
    <columns>Source__c</columns>
    <columns>CORE.USERS.ALIAS</columns>
    <filterScope>Everything</filterScope>
    <label>All Leads</label>
</listViews>

Unfortunately, the built-in Apex Metadata class can only reference custom metadata types and does not have an interface for standard metadata.

Additionally, you can access list view information through the User Interface API List View endpoints to get results given the API name of a list view and the associated object:

https://[MY_DOMAIN].my.salesforce.com/services/data/v49.0/ui-api/list-info/Account/List_API_Name

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.