I have a user case where the community user needs to see all the appointments of all the contacts from their parent account.Here is the Code I have:

public class AppointmentListController {

public String AppFilterId {get; set;}
private Integer pageSize = 10;
private String baseQuery ='SELECT Name, contact.name, Status__c FROM appointment__c WHERE contact IN (SELECT Id FROM Contact WHERE AccountId = :myContact.AccountId)';

public AppointmentListController(){
    Contact myContact=[select id,accountid from contact where id in(select contactId from user where id=:userinfo.getuserid())];

public ApexPages.StandardSetController AppSetController {
        if(AppSetController == null){
            AppSetController = new ApexPages.StandardSetController(Database.getQueryLocator(baseQuery));
            if(AppFilterId != null)
        return AppSetController;

public AppointmentListController(ApexPages.StandardSetController c) {   }

public void firstPage()

public void lastPage()

public void next()

public void prev()

public List<appointment__c> getAppoinments()
    return (List<appointment__c>)AppSetController.getRecords();

public SelectOption[] getAppoinmentExistingViews(){
    return AppSetController.getListViewOptions();

public PageReference resetFilter()
    AppSetController = null;
    return null;

and this is my visualforce page:

<apex:page controller="AppointmentListController" sidebar="false" showHeader="false">

<apex:form id="pageForm">

   <apex:actionStatus id="ajaxStatus" startText="Loading..."  stopText=""/>

 <apex:pageBlock title="Appoinments">
    <apex:pageBlockButtons >
            <apex:commandButton action="{!firstPage}" value="|<<" reRender="AppTable"  status="ajaxStatus" />
            <apex:commandButton action="{!prev}" value="Prev" reRender="AppTable"  status="ajaxStatus" />
            <apex:commandButton action="{!next}" value="Next" reRender="AppTable"  status="ajaxStatus" />
            <apex:commandButton action="{!lastPage}" value=">>|" reRender="AppTable"  status="ajaxStatus" />

     <apex:pageBlockTable value="{!Appoinments}" var="item" id="AppTable">
         <apex:column value="{!item.name}" headerValue="Appoinment Name"/>
         <apex:column value="{!item.Status__c}" headerValue="Status"/>
         <apex:column value="{!item.contact}" headerValue="Contact"/>


When I add this page to the community,I am getting the error "Error: Error occurred while loading a Visualforce page." What am I doing wrong here?

  • Did you give the community user profile access to the VF page and add the VF page to the community? – Dave Humm Aug 15 '17 at 13:18
  • Yes I have given the community user profile access to both apex controller and vf page and added the page to the community. – Sooraj Aug 15 '17 at 13:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.