You need to sign in to do that
Don't have an account?
sooraj kesavadas
Displaying standard set controller in visual force?
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:
and this is my visualforce page:
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?
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 this is my visualforce 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>
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?
PawanKumar
Are you able to test the above as Admin?
sooraj kesavadas
Hi Pawan, I am not sure how to do that, however I tried all the soql queries in a different class and it is returning the expected result.