lightning:listView don't support changing list views, so I get listview name using SOQL in order to make custom list view changer.

It's success, so next, I want to make custom list view creater.

I thought there is some method to create list view using SOQL, but I couldn't find such a method.

Is it possible or there is no method to create list view other than use default way?

SOQL to get list view data

public static final String objectName = 'MyObject__c';
public static List<listView> getListViewInfo(String objectName){
    List<ListView> listViewInfo = 
    [SELECT Name, DeveloperName 
     FROM ListView 
     WHERE SObjectType =: objectName];
     return listViewInfo;
  • You can create this via code using the metadata API. You would have to download one of the wsdl files, use the wsld to Apex generator to create a wrapper for it and use that to create a soap envelope with the request. Refer this link: salesforce.stackexchange.com/questions/24543/… Jan 7, 2020 at 6:56
  • need to download Metadata WSDL as static resource?
    – Hayato
    Jan 7, 2020 at 8:39

1 Answer 1


ListView is a read-only sObject representing a metadata entity. To modify metadata, you must use the Metadata API.

There is an Apex wrapper, apex-mdapi, available from a third party.

Working with the Metadata API is not to be done too lightly in an active production org. Be aware that the running user must have enough permission to make changes to metadata in Setup to access the Metadata API at all. Granting these permissions to non-system administrator users requires opening large holes in your org's security infrastructure.

  • Thank you for the advice. I just want to custom my lightning:listView as like default list view. If you know some method to do this?
    – Hayato
    Jan 8, 2020 at 3:03
  • I'm not sure what you're asking.
    – David Reed
    Jan 8, 2020 at 3:57
  • Creating or deleting of list views and Modifying of the list view filter is not supported in lightning:listView component, but I need them. so I want to know how to make these function. Using metadata seems have security problem, so I wonder if there are any other way.
    – Hayato
    Jan 8, 2020 at 4:04

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.