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
David Brown 82David Brown 82 

Visualforce page from filtered list view not displaying filtered on site

I have a VisualForce page which displays records from a filtered list view. When I preview the VF page it shows the filtered list. However, when I display that same VF page on a Sites page it reverts to an unfiltered list of all the records in the object. Here's my VF page code:

<apex:page standardController="Volunteer_Position__c" recordSetVar="positions" showHeader="false">
    <apex:pageBlock >
         <apex:pageBlockTable value="{!positions}" var="position" id="Actively_recruiting_positions__c">
              <apex:column value="{!position.Name}"/>
                          <apex:column value="{!position.Apply_form_link__c}"/>
         </apex:pageBlockTable>
    </apex:pageBlock>
</apex:page> 

It's supposed to display only the volunteer positions to which I am actively recruiting.
DixitSDixitS
Site guest user doesn't have access on record, that's why you are not getting values. Create an extension class of the VF page without sharing the keyword .
David Brown 82David Brown 82
Thank you DixitS. What do you mean when you say I am not getting values? I'm getting all the records in the object - see here (https://www.visioncarecharity.org/volunteer-sign-up/).
Are you suggesting I do something like this? https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_controller_extension.htm
That is extremely advanced for me. Not sure what you mean by not sharing the keyword. 
DixitSDixitS
Hi David,
To understand it better, can you provide me with the screenshot of VF page with the filtered list (expected outcome, one which you are getting in preview) and VF page without filter (sites output). 
David Brown 82David Brown 82
Hi DixitS,
It's gone really wierd now.
The Visual Force Page is called VolunteerPositionsActive. When I'm in visual force pages setup looking at the list of VF pages, if I click on the preview I get these 14 records, which is how I want it (although I will remove the Active tick box when I can get it working properly) 
https://vchp--c.visualforce.com/apex/VolunteerPositionsActive
User-added image


The site is http://vchp.force.com/positions
In site edit for positions, the Active Site Home Page is VolunteerPositionsActive and when I preview that VF I get the same 14 records.

When I go to the site it takes me to https://vchp.secure.force.com/positions/ and I get this, which has 17 records and includes the inactive ones (but strangely no tick boxes)
User-added image