You need to sign in to do that
Don't have an account?

Query for list view Id's and names
How do I query for all the list view names and ids for a specific sObject via apex?
I don't see this in the API or as a describe object option.
Thanks,
Matt
Hi Lakshmi,
As far as I know, you cannot access list views via SOQL queries. It's built into the SObject. We created a method which might help you see how we use List Views in APEX. Our Task was to get a LIST VIEW URL based on the LABEL (view name). You cannot retrieve ID's based on the LIst View API Name as the describe sobject only returns a ListOption which is a value and label.
Requirement
Display a link on your own visualforce page. When clicked it will take a user to the the All Accounts List View for the Account Object.
Zach
All Answers
Good question, this would be very useful for the enhancedList VF component.
Any ideas??
Henry
Here's a post on how to get it working, along with all the needed workaround for a bug you're going to hit if you use a dynamic listId.
https://lameness.info/wordpress/11.05.2010/the-apexenhancedlist-component-is-in-fact-broken/
It's an ugly hack on top of an ugly hack, but it works well so far. Just don't use them inside an apex:panelBar or they don't work right.
That link above is borked. Was it a typo?
I've also had trouble obtaining these IDs. Eclipse ID only pulls the list view 'name' and 'label'.
Hi Peterson,
The link which you have provide is not opened now. Can you help me how to use the listviewid in salesforce queries. Please help me..
Thanks,
Lakshmi.
Hi Lakshmi,
As far as I know, you cannot access list views via SOQL queries. It's built into the SObject. We created a method which might help you see how we use List Views in APEX. Our Task was to get a LIST VIEW URL based on the LABEL (view name). You cannot retrieve ID's based on the LIst View API Name as the describe sobject only returns a ListOption which is a value and label.
Requirement
Display a link on your own visualforce page. When clicked it will take a user to the the All Accounts List View for the Account Object.
Zach
So, if I'm dynamically building a <apex:enhancedList listId="{!listViewId}" /> what everyone's saying is there's no way to do it in Apex because the list view IDs aren't available--not even using the (broken) StandardSetController.GetListViewOoptions()?
So the only alternative is to make metadata calls from Apex back to my org to find the list views?