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
Graham ButcherGraham Butcher 

visual force page not working when made public

I'm new to salesforce and am working on a developer edition while I'm learning how to use it.
I have created a Visual Force page as per one of the tutorials. It works when not on the public site.
It's just a list of contacts with a filter and pagination functionality.
When I put it on the public facing site, the initial list shows fine, but when I try any of the functionality, I just get a blank page.
From the browser console, I get the following errors:
Loading failed for the <script> with source “https://butch-developer-edition.eu16.force.com/jslibrary/1530643972000/sfdc/VFState.js”.

Loading failed for the <script> with source “https://butch-developer-edition.eu16.force.com/jslibrary/1530643972000/sfdc/main.js”.

Loading failed for the <script> with source “https://butch-developer-edition.eu16.force.com/jslibrary/jslabels/1537578900000/en_US.js”.

ReferenceError: GenericSfdcPage is not defined

ReferenceError: MenuButtonRounded is not defined

Loading failed for the <script> with source “https://butch-developer-edition.eu16.force.com/jslibrary/1530643972000/sfdc/MarketingSurveyResponse.js”.

ReferenceError: setFocusOnLoad is not defined

ReferenceError: closePopupOnBodyFocus is not defined
So it looks like some sort of permissions issue for the guest profile, but I have no idea what.
The public facing site is at https://butch-developer-edition.eu16.force.com/
The source code for the page is:
<apex:page standardController="Contact" recordSetVar="contacts">
  <apex:form>
    <apex:pageBlock title="Contacts List" id="contacts_list">
        Filter: 
        <apex:selectList value="{! filterId }" size="1">
            <apex:selectOptions value="{! listViewOptions }"/>
            <apex:actionSupport event="onchange" reRender="contacts_list"/>
        </apex:selectList>

        <!-- Contacts List -->
        <apex:pageBlockTable value="{! contacts }" var="ct">
            <apex:column value="{! ct.Name }"/>
        </apex:pageBlockTable>

        <!-- Pagination -->
        <table style="width: 100%">
            <tr>
                <td>
                    Page: <apex:outputText value=" {!PageNumber} of {! CEILING(ResultSize / PageSize) }"/>
                </td>
                <td>
                    <apex:commandLink action="{! First }" value="« First" rendered="{! HasPrevious }"/>
                    <apex:commandLink style="color: #ccc;" value="« First" rendered="{! NOT(HasPrevious) }"/>
                </td>
                <td align="center">
                    <!-- Previous page -->
                    <!-- active -->
                    <apex:commandLink action="{! Previous }" value="« Previous" rendered="{! HasPrevious }"/>
                    <!-- inactive (no earlier pages) -->
                    <apex:outputText style="color: #ccc;" value="« Previous" rendered="{! NOT(HasPrevious) }"/>
                    &nbsp;&nbsp;  

                    <!-- Next page -->
                    <!-- active -->
                    <apex:commandLink action="{! Next }" value="Next »" rendered="{! HasNext }"/>
                    <!-- inactive (no more pages) -->
                    <apex:outputText style="color: #ccc;" value="Next »" rendered="{! NOT(HasNext) }"/>
                </td>
                <td>
                    <apex:commandLink action="{! Last }" value="Last »" rendered="{! HasNext }"/>
                    <apex:commandLink style="color: #ccc;" value="Last »" rendered="{! NOT(HasNext) }"/>
                </td>

                <td align="right">
                    Records per page:
                    <apex:selectList value="{! PageSize }" size="1">
                        <apex:selectOption itemValue="5" itemLabel="5"/>
                        <apex:selectOption itemValue="20" itemLabel="20"/>
                        <apex:actionSupport event="onchange" reRender="contacts_list"/>
                    </apex:selectList>
                </td>
            </tr>
        </table>
    </apex:pageBlock>
  </apex:form>
</apex:page>
Can someone point me in the right direction please.
I'm using the Summer '18 release and only using the lightning interface, so not familiar with the classic interface at all, so please hold my hand if giving me replies that involve classic.

 
Khan AnasKhan Anas (Salesforce Developers) 
Hi Graham,

I trust you are doing very well.

Make sure the "guest" user for the site has Read permission for the Contact object on its profile. You can't access the profile for the guest user through the normal Profile list page in Setup; instead, click on the Public Access Settings button from your site's detail page. On the profile, go all the way to the bottom of the page and make sure the Read permission is checked. If it's still not working, ensure the Field Level Security settings also correct for that profile. The FLS settings are controlled about mid-way down on the same page.

These are the steps that you needed to check before you test VF pages in SITE .
  • Check Object Level Permission (Whatever object you are using in the VF page , make sure they have the required permissions enabled).
  • The next thing is FIELD Level Permissions (whatever field is displayed on the page needs to have read/edit permissions based on their usage).
  • The next thing is Record Type Settings. (If the object has any record types assigned, make sure that is marked as default record type for you to view it on Sites).
  • Add the VF page and Apex class in Enabled VisualForce Pages and Enabled Apex Classes.

Reference: 
https://stackoverflow.com/questions/7885031/data-shows-when-page-accessed-from-internally-but-not-on-public-site

https://salesforce.stackexchange.com/questions/41576/displaying-visualforce-pages-in-public-sites

Also, make sure you explicitly put <apex:page cache="false"> in your page.


I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future.

Thanks and Regards,
Khan Anas
Graham ButcherGraham Butcher
Hi Khan
It isn't the object permission as you can see from the link provided (https://butch-developer-edition.eu16.force.com/).  It clearly has access to the data, but when I do something like change the page size to 5, I then get the blank page.

Tried the cache thing - no change.

Couldn't find (On the profile, go all the way to the bottom of the page and make sure the Read permission is checked.) though data access is not the problem anyway.

Where do I find "Add the VF page and Apex class in Enabled VisualForce Pages and Enabled Apex Classes." ?
 
Graham ButcherGraham Butcher
Found the "Enabled pages and classes" (was on the same page - doh).  But that's also in order, otherwise the page wouldn't show at all, I guess.
So still no go.