3

I created a very simple VF page that I embed in an iframe on a home tab for a group of users, to show a select list of accounts, using an existing List View to filter the results. The issue is that when the page loads it defaults to Recently Viewed records rather than the list view I want. Can I specify a list view to load?

<apex:page standardController="Account" recordSetvar="accounts" showHeader="false" sidebar="false">
  <apex:pageBlock title="Select 'EFN Programs' to view directory">
    <apex:form id="theForm">
    <apex:panelGrid columns="2">
      <apex:outputLabel value="View:"/>
      <apex:selectList value="{!filterId}" size="1">
        <apex:actionSupport event="onchange" rerender="list"/>
        <apex:selectOptions value="{!listviewoptions}"/>
      </apex:selectList>
    </apex:panelGrid>
    <apex:pageBlockSection >
      <apex:dataList var="a" value="{!accounts}" id="list">
        {!a.name}<br></br>
        Program Director: {!a.PO_Program_Manager__r.name}<br></br>
        Region focus: {!a.PO_Region__c}<br></br><br></br>
      </apex:dataList>
    </apex:pageBlockSection>
  </apex:form> 
  </apex:pageBlock>
</apex:page>
3

You can assign a value for the list using StandardSetController.setFilterId(). You can do this in Visualforce or Apex Code. For example, you can specify a list view filter ID in the constructor of an extension.

2
  • Thanks for answering! I would love to do this in Visualforce but can't find the apex: command with an appropriate attribute to specify the list view I want to display. How exactly would I do that? – user5263 Jan 13 '14 at 22:27
  • @user5263 In Professional Edition, you'd need some tricky JavaScript (onload, change list view, refresh), but if you can use Apex Code (e.g. DE, EE, UE), add a class like public with sharing class mypageextension { public mypageextension(apexpages.standardsetcontroller con) { con.setfilterId( /* some ID value */ ); } }, and add extensions="mypageextension" to the apex:page. – sfdcfox Jan 13 '14 at 23:14

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.