You need to sign in to do that
Don't have an account?
Allen Moy
Challenge with SOQl to VisualForce Page
I used the example on this site as a model to build my custom controller and page but my resulting page has no data. What am I missing?
Here is my custom controller:
public with sharing class MarketReservationDetails {
public List <Farmers_Market_Reservation__c> Records {get; set;}
public MarketReservationDetails() {
Records =
[SELECT id, Farmers_Market_Day__c, Producer_Type__c, Producer_Name__c,
Producer_Stall_Space__c FROM Farmers_Market_Reservation__c
WHERE RecordTypeID='01216000001IiQx'
AND Farmers_Market_Day__c=:ApexPages.currentPage().getParameters().get('id')];
}
}
And here is my page:
<apex:page controller="MarketReservationDetails" sidebar="false" showHeader="false">
<apex:form >
<apex:pageBlock >
<apex:pageMessages />
<apex:pageBlock >
Note: All modifications made on the page will be lost if Return button is clicked without clicking the Save button first.
</apex:pageBlock>
<apex:pageBlockTable value="{!Records}" var="R">
<apex:outputField value="{!R.Producer_Type__c}"/>
<apex:outputField value="{!R.Producer_Name__c}"/>
<apex:outputField value="{!R.Producer_Stall_Space__c}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
Here is my custom controller:
public with sharing class MarketReservationDetails {
public List <Farmers_Market_Reservation__c> Records {get; set;}
public MarketReservationDetails() {
Records =
[SELECT id, Farmers_Market_Day__c, Producer_Type__c, Producer_Name__c,
Producer_Stall_Space__c FROM Farmers_Market_Reservation__c
WHERE RecordTypeID='01216000001IiQx'
AND Farmers_Market_Day__c=:ApexPages.currentPage().getParameters().get('id')];
}
}
And here is my page:
<apex:page controller="MarketReservationDetails" sidebar="false" showHeader="false">
<apex:form >
<apex:pageBlock >
<apex:pageMessages />
<apex:pageBlock >
Note: All modifications made on the page will be lost if Return button is clicked without clicking the Save button first.
</apex:pageBlock>
<apex:pageBlockTable value="{!Records}" var="R">
<apex:outputField value="{!R.Producer_Type__c}"/>
<apex:outputField value="{!R.Producer_Name__c}"/>
<apex:outputField value="{!R.Producer_Stall_Space__c}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
Could you please check whether you are have corresponding data in your environment, if yes then first try to remove the filter conditions and check the results. If you get the results without filters then look for the right filters.
Regards,
Mahesh
first of all if there is error in your query. you hav to use colon ':' before id.like following:-
Account= [SELECT id,name FROM Account where id=:'0012800000IbWgx']; delete the AND statement from the query;
second if you want to fetch a single record you don't have need to use List...
I found below issue in your query
1) Never use the hardcord ID in query. Try to modify like below 2) I hope you are passing valid Record ID of Farmers_Market_Day__c in URL ?
Please let us know if this will help you