Skip to main content
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 {

get{

if(AppSetController == null){

AppSetController = new ApexPages.StandardSetController(Database.getQueryLocator(baseQuery));

AppSetController.setPageSize(pageSize);

if(AppFilterId != null)

{

AppSetController.setFilterId(AppFilterId);

}

}

return AppSetController;

}set;

}

public AppointmentListController(ApexPages.StandardSetController c) { }

public void firstPage()

{

AppSetController.first();

}

public void lastPage()

{

AppSetController.last();

}

public void next()

{

if(AppSetController.getHasNext())

{

AppSetController.next();

}

}

public void prev()

{

if(AppSetController.getHasPrevious())

{

AppSetController.previous();

}

}

public List<appointment__c> getAppoinments()

{

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

}

public SelectOption[] getAppoinmentExistingViews(){

return AppSetController.getListViewOptions();

}

public PageReference resetFilter()

{

AppSetController = null;

AppSetController.setPageNumber(1);

return null;

}}

 

And here is my vf page:

 

 

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

<apex:form id="pageForm">

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

<br/><br/>

<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:pageBlockButtons>

<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"/>

</apex:pageBlockTable>

</apex:pageBlock>

</apex:form>

</apex:page>

 

I have given the community user profile access to both the vf page and apex controller but 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? ​
1 risposta
  1. 15 ago 2017, 13:40
    How are you calling this VF page?

     

    Are you passing any Id?

     

    try passing id like this> in your URL after /apex/vfpagename?id='any valid account id in your org here'

     

    Also,  I would Suggest you to Please redirect your question into Salesforce Developer Forum and Stack Exchange. As this community is based on Configuration and Customization Part.

     

    https://developer.salesforce.com/forums#!/feedtype=RECENT&criteria=ALLQUESTIONS&

     

    https://salesforce.stackexchange.com/

     

    Thanks,

     

    Amit Singh
0/9000