1

I have a simple visualforce page that I want to return all account records:

<apex:page standardController="Account" recordSetVar="accounts">
    <apex:repeat value="{!accounts}" var="a" >
        <li>
            <apex:outputLink value="/{! a.id }">LINK</apex:outputLink>
        </li>
    </apex:repeat>
</apex:page>

This page doesn't return all account records - one thing I've noticed is that in lightning experience the returned accounts seem to be affected by the most recent list view used on the 'Accounts' tab - so if I use the 'Recently Viewed' view, then open this visualforce page then most (but not all) of the recently viewed Accounts appear. If I select 'All Accounts' view on the Account tab, then open the visualforce page, all accounts appear.

How can i set the visualforce page so all accounts appear every time, irrespective of the last view used on the Account tab?

2

You can't really default it without a little bit of Apex. What you can do is add a list with all the available listviews and let the user choose.

The below example, taken from the docs, will help you with the latter. If you are ready for some apex, write an extension that defaults the filterId property to the listview of your choosing.

<apex:page standardController="Account" recordSetvar="accounts">
  <apex:pageBlock title="Viewing Accounts">
  <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}
      </apex:dataList>
    </apex:pageBlockSection>
  </apex:form> 
  </apex:pageBlock>
</apex:page>

Reference doc is here

NOTE

There is yet a 3rd option, but I haven't tested it so I will mention it in passing. You may be able to pass a URL parameter (&filterId=XXXX) and have it default, or you may put that URL parameter into a property named filterId have it work. As I said, I have not tested the above solution so please take it as something to explore, not as a solution.

1

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.