Find your content:

Search form

You are here

Getting the view names from the List View dropdown

 
Share

In our org lot of people are creating custom list views and then deleting them.

As admin we wanted the list view names displayed under the Views drop down.

Are these names stored in any object which we can query. Can anyone provide any suggestions to query and retrieve the list view names for a specific object.


Attribution to: user5352

Possible Suggestion/Solution #1

Unfortunately there is no way to query this information using SOQL or via Platform Reports.

However you can use some Apex code or the Metadata API (again call via code). For example you could run the following from Developer Console to dump the List View names to the Debug log.

ApexPages.StandardSetController controller = 
    new ApexPages.StandardSetController(Database.getQueryLocator('select Id from Account Limit 1'));
List<System.SelectOption> listViews = controller.getListViewOptions();
for(System.SelectOption listView : listViews)
{
    System.debug('List View Name : ' + listView.getValue());
    System.debug('List View Label : ' + listView.getLabel());
}

Gives the following...

18:19:50.134 (134639872)|USER_DEBUG|[6]|DEBUG|List View Name : 00BG000000702tHMAQ

18:19:50.134 (134705838)|USER_DEBUG|[7]|DEBUG|List View Label : New This Week

18:19:50.134 (134760958)|USER_DEBUG|[6]|DEBUG|List View Name : 00BG000000702tSMAQ

18:19:50.134 (134785511)|USER_DEBUG|[7]|DEBUG|List View Label : New Last Week

18:19:50.134 (134835719)|USER_DEBUG|[6]|DEBUG|List View Name : 00BG000000702tjMAA

18:19:50.134 (134860314)|USER_DEBUG|[7]|DEBUG|List View Label : Platinum and Gold SLA Customers

18:19:50.134 (134907861)|USER_DEBUG|[6]|DEBUG|List View Name : 00BG000000702trMAA

18:19:50.134 (134931455)|USER_DEBUG|[7]|DEBUG|List View Label : Recently Viewed Accounts

18:19:50.134 (134980144)|USER_DEBUG|[6]|DEBUG|List View Name : 00BG000000702tsMAA

18:19:50.135 (135008341)|USER_DEBUG|[7]|DEBUG|List View Label : All Accounts

18:19:50.135 (135057102)|USER_DEBUG|[6]|DEBUG|List View Name : 00BG000000702u0MAA

18:19:50.135 (135079985)|USER_DEBUG|[7]|DEBUG|List View Label : My Accounts


Attribution to: Andrew Fawcett
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/31627

My Block Status

My Block Content