+ Start a Discussion
michaelw_dcmichaelw_dc 

VisualForce Page not listing accounts on Site

This used to work at one point, and now it does not.  I've observed that the VisualForce page still lists accounts correctly, but when published to a "Site" homepage, it does not.  This suggests a permissions problem, but I don't see anything standing out as incorrect.

This entire process of producing the accounts seems to consist of: a user, a user profile, a visualForce page, a custom Apex class that sets the page size to 2000, and the site page itself.
  • For the custom Apex class, I've verified that the user profile is enabled for it in the security settings.
  • For the Visualforce page, it works perfectly, listing out all the accounts.
  • For the user profile, I've verified that the object settings includes Read permission on the Accounts object, and possesses the Apex Class Access to the custom Apex class.
  • For the site page, editing public access settings takes me to the same user profile that possesses Read permission on the Accounts object.
  • For the user itself, it possesses the guest license and uses the profile with the Read permission on the accounts object.
I've not done much work with Salesforce, so perhaps its something silly and obvious that I am missing.  So, does anyone know what I might be missing, here?  I've tried toggling things that look like they might be associated with reading accounts, such as system permissions to access the Salesforce API or to access the Apex REST API, with no luck.
Best Answer chosen by michaelw_dc
SarvaniSarvani
Hi Michael,

Did you check the Spring 20' realease notes on guest user access to records using sharing settings. https://releasenotes.docs.salesforce.com/en-us/spring20/release-notes/rn_networks_guest_sharing_security_alert.htm 

By default  Org's guest user record access is set to private. For the site to display records for guest users trying enabling the checkbox and setup sharing rules for the user on desired object.

Step1. As shown in the image below navigate to sharing settings and enable the checkbox

User-added image

Step 2. Create a new sharing rule on Account object like below using Guest user based criteria. (Ex: Accont name not equal to NULL)
User-added image

Hope this helps! Please mark as best if it solves your issue

Thanks

All Answers

David Zhu 🔥David Zhu 🔥
It is most likely caused by account sharing.

Would you change your apex class to without sharing to see if accounts listed on site?

​​​​​​
SarvaniSarvani
Hi Michael,

Did you check the Spring 20' realease notes on guest user access to records using sharing settings. https://releasenotes.docs.salesforce.com/en-us/spring20/release-notes/rn_networks_guest_sharing_security_alert.htm 

By default  Org's guest user record access is set to private. For the site to display records for guest users trying enabling the checkbox and setup sharing rules for the user on desired object.

Step1. As shown in the image below navigate to sharing settings and enable the checkbox

User-added image

Step 2. Create a new sharing rule on Account object like below using Guest user based criteria. (Ex: Accont name not equal to NULL)
User-added image

Hope this helps! Please mark as best if it solves your issue

Thanks
This was selected as the best answer
michaelw_dcmichaelw_dc
Your explicit instructions worked like a charm.  Much appreciated, Sarvani!