Create VisualForce Tab to Display Static List View for Standard or Custom Object

Use Case:

You would like to create a custom tab to display a specific list view for a standard or custom object rather than use the standard tab view that only displays recently viewed records.

Solution:

  1. From the standard or custom object tab, Edit an existing view or ‘Create New View.’
  2. Ensure that you give the view a Name, that you specify filter criteria, that you select the fields to display, and that you restrict visibility as necessary.
  3. When the view has been saved and you are returned to the tab, select the view from the dropdown.
  4. Copy the 15-character view ID in the URL and paste it to Notepad, or write it down.
  5. Create a new VisualForce page (Setup / App Setup / Develop / Pages) using the sample code provided below.
  6. Create a new VisualForce tab (Setup / App Setup / Create / Tabs) and select the VisualForce Page created in Step #5, provide a Tab Label, Tab Name, and Tab Style, and then apply the desired profile visibility for the new tab.
  7. Optional – hide the tab for the standard or custom object if your new tab is a replacement for the default tab.
  8. If you want to change the View that is displayed in the tab at any time, simply navigate back to the standard tab for the object and Edit the view to meet requirements.

The VisualForce Page code:

Note: Replace “xxxxxxxxxxxxxxx” with the 15-character ID of the View that you captured in Step #4 above.  You can adjust the ‘height’, ‘customizable’, and ‘rowsPerPage’ values as desired.

<apex:page >
<apex:enhancedList listId="xxxxxxxxxxxxxxx" height="600" customizable="false" rowsPerPage="25"/>
</apex:page>

Tip submitted by:

Michael Topalovich
Delivered Innovation

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>