2

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.

3

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

  • Thank you so much for your response. It helped a Great Deal!!! – user5352 Apr 5 '14 at 14:24
  • 1
    Make sure you construct the StandardSetController with a query locator if you are running this as anonymous apex. I tried using a list as a constructor and got the error message: UNKNOWN_EXCEPTION: No Visualforce context has been established! – martin Aug 31 '15 at 3:43

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.