function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Passing list view id on Visualforce Page


I need to pass one list view called "my open cases"  in the visuaforce page that will ony show open cases of the who logged in. I mean if I login I should see only my open cases but if bob logs in, he should see only his open case. I started with something but couldn't figure it out. Here is my VFP and apex code. Please help

<apex:page controller="retrieveCase" tabStyle="Case">
    <apex:pageBlock >
        My Open Cases
        <apex:pageBlockTable value="{!cases}" var="c" rows="50" id="cases_table" > 
            <apex:column >
              <a target="_blank" href="/{!}">{!c.casenumber}</a>
              <apex:facet name="header">Case Number</apex:facet>
          <apex:column >
             <a target="_blank" href="/{!c.accountid}">{!}</a>
             <apex:facet name="header">Account Name</apex:facet>
            <apex:column value="{!c.status}"/>

Apex Class:
public class retrieveCase {

    public String getContactName() {
        return 'My Open';

    public List<Case> getCases() {
        return [SELECT casenumber,,status FROM Case
                WHERE = 'Username' AND status != 'Open' limit 20];

SonamSonam (Salesforce Developers) 
You can create a VF page by directly using the ID of the list view as shown below:

<apex:page >
<apex:enhancedList type="Case" height="300" rowsPerPage="10" listid="00B28000001IDB4" /> //this is the ID of the My open case list view

This listID is the database ID of the desired list view. When editing a list view definition, this ID is the 15-character string after 'fcf=' in the browser's address bar.