You need to sign in to do that
Don't have an account?
Admin User 10568
Error Accessing Fields from Custom Apex Class
Hi,
Hoping someone can help me here.
I've written the following custom apex class:
public class PriceListAscending{
public String sortOrder = 'Name';
public list<REPRO__Project__c> getEvents() {
list<REPRO__Project__c> results = Database.query(
' SELECT Name, REPRO__Street__c, REPRO__City__c,(SELECT Property_Level__c,Price_List_Property_Name__c,REPRO__Type__c,REPRO__Bdr__c,REPRO__Bth__c,REPRO__Study__c,REPRO__Internal_Size__c,REPRO__External_Size__c,REPRO__Car__c,REPRO__List_Price__c,REPRO__Status__c from REPRO__Properties__r) ' +
' FROM REPRO__Project__c ' +
' ORDER BY ' + sortOrder + ' ASC '
);
return results;
}
}
It runs without an error. I tested the query. It returns the requested data. The subquery is returned as one column. It would be nice if it was a column for each field requested.
My aim is to use the data from the query to populate an apex block table for a Visualforce page. Could someone let me know where I'm going wrong calling the fields and sub query fields?
Here is my page:
<apex:page Controller="PriceListAscending" renderAs="pdf" showHeader="false" >
<apex:pageBlock>
<h1 style= "text-align: center;">{!Events.Name}</h1>
<p style= "text-align: center;">{!Events.REPRO__Street__c} {!Events.REPRO__City__c} <br/> Price List as of {! TODAY()} </p>
<apex:pageBlockTable value="{!Events}" var="e" align="center" cellpadding="2" border="4" style=" font-weight: bold; text-align: center; " >
<apex:column value="{!e.REPRO__Properties__r.Property_Level__c}" style="padding: 10px;order-bottom: 1px solid #ddd;border: 1px solid black; text-align: center; " />
<apex:column value="{!e.REPRO__Properties__r.Price_List_Property_Name__c}" style="padding: 10px;order-bottom: 1px solid #ddd;border: 1px solid black; text-align: center; " />
<apex:column value="{!e.REPRO__Properties__r.REPRO__Type__c}" style="padding: 10px;order-bottom: 1px solid #ddd;border: 1px solid black; text-align: center; " />
<apex:column value="{!e.REPRO__Properties__r.REPRO__Bdr__c}" style="padding: 10px;order-bottom: 1px solid #ddd;border: 1px solid black; text-align: center; " />
<apex:column value="{!e.REPRO__Properties__r.REPRO__Bth__c}" style="padding: 10px;order-bottom: 1px solid #ddd;border: 1px solid black; text-align: center; " />
<apex:column value="{!e.REPRO__Properties__r.REPRO__Study__c}" style="padding: 10px;order-bottom: 1px solid #ddd;border: 1px solid black; text-align: center; " />
<apex:column value="{!e.REPRO__Properties__r.REPRO__Internal_Size__c}" style="padding: 10px;order-bottom: 1px solid #ddd;border: 1px solid black; text-align: center; " />
<apex:column value="{!e.REPRO__Properties__r.REPRO__External_Size__c}" style="padding: 10px;order-bottom: 1px solid #ddd;border: 1px solid black; text-align: center; " />
<apex:column value="{!e.REPRO__Properties__r.REPRO__Car__c}" style="padding: 10px;order-bottom: 1px solid #ddd;border: 1px solid black; text-align: center; " />
<apex:column value="{!e.REPRO__Properties__r.REPRO__List_Price__c}" style="padding: 10px;order-bottom: 1px solid #ddd;border: 1px solid black; text-align: center; " />
<apex:column value="{!e.REPRO__Properties__r.REPRO__Status__c}" style="padding: 10px;order-bottom: 1px solid #ddd;border: 1px solid black; text-align: center; " />
</apex:pageBlockTable>
</apex:pageBlock>
</apex:page>
Here is the current error: Unknown property 'VisualforceArrayList.Name'
Any help would be greatly appreciated.
Hoping someone can help me here.
I've written the following custom apex class:
public class PriceListAscending{
public String sortOrder = 'Name';
public list<REPRO__Project__c> getEvents() {
list<REPRO__Project__c> results = Database.query(
' SELECT Name, REPRO__Street__c, REPRO__City__c,(SELECT Property_Level__c,Price_List_Property_Name__c,REPRO__Type__c,REPRO__Bdr__c,REPRO__Bth__c,REPRO__Study__c,REPRO__Internal_Size__c,REPRO__External_Size__c,REPRO__Car__c,REPRO__List_Price__c,REPRO__Status__c from REPRO__Properties__r) ' +
' FROM REPRO__Project__c ' +
' ORDER BY ' + sortOrder + ' ASC '
);
return results;
}
}
It runs without an error. I tested the query. It returns the requested data. The subquery is returned as one column. It would be nice if it was a column for each field requested.
My aim is to use the data from the query to populate an apex block table for a Visualforce page. Could someone let me know where I'm going wrong calling the fields and sub query fields?
Here is my page:
<apex:page Controller="PriceListAscending" renderAs="pdf" showHeader="false" >
<apex:pageBlock>
<h1 style= "text-align: center;">{!Events.Name}</h1>
<p style= "text-align: center;">{!Events.REPRO__Street__c} {!Events.REPRO__City__c} <br/> Price List as of {! TODAY()} </p>
<apex:pageBlockTable value="{!Events}" var="e" align="center" cellpadding="2" border="4" style=" font-weight: bold; text-align: center; " >
<apex:column value="{!e.REPRO__Properties__r.Property_Level__c}" style="padding: 10px;order-bottom: 1px solid #ddd;border: 1px solid black; text-align: center; " />
<apex:column value="{!e.REPRO__Properties__r.Price_List_Property_Name__c}" style="padding: 10px;order-bottom: 1px solid #ddd;border: 1px solid black; text-align: center; " />
<apex:column value="{!e.REPRO__Properties__r.REPRO__Type__c}" style="padding: 10px;order-bottom: 1px solid #ddd;border: 1px solid black; text-align: center; " />
<apex:column value="{!e.REPRO__Properties__r.REPRO__Bdr__c}" style="padding: 10px;order-bottom: 1px solid #ddd;border: 1px solid black; text-align: center; " />
<apex:column value="{!e.REPRO__Properties__r.REPRO__Bth__c}" style="padding: 10px;order-bottom: 1px solid #ddd;border: 1px solid black; text-align: center; " />
<apex:column value="{!e.REPRO__Properties__r.REPRO__Study__c}" style="padding: 10px;order-bottom: 1px solid #ddd;border: 1px solid black; text-align: center; " />
<apex:column value="{!e.REPRO__Properties__r.REPRO__Internal_Size__c}" style="padding: 10px;order-bottom: 1px solid #ddd;border: 1px solid black; text-align: center; " />
<apex:column value="{!e.REPRO__Properties__r.REPRO__External_Size__c}" style="padding: 10px;order-bottom: 1px solid #ddd;border: 1px solid black; text-align: center; " />
<apex:column value="{!e.REPRO__Properties__r.REPRO__Car__c}" style="padding: 10px;order-bottom: 1px solid #ddd;border: 1px solid black; text-align: center; " />
<apex:column value="{!e.REPRO__Properties__r.REPRO__List_Price__c}" style="padding: 10px;order-bottom: 1px solid #ddd;border: 1px solid black; text-align: center; " />
<apex:column value="{!e.REPRO__Properties__r.REPRO__Status__c}" style="padding: 10px;order-bottom: 1px solid #ddd;border: 1px solid black; text-align: center; " />
</apex:pageBlockTable>
</apex:pageBlock>
</apex:page>
Here is the current error: Unknown property 'VisualforceArrayList.Name'
Any help would be greatly appreciated.
<apex:column>
<apex:pageBlockTable value="{!e.REPRO__Properties__r}" var="custom">
<apex:column value ="{!custom.Property_Level__c}"/>
</apex:pageBlockTable>
</apex:column>
Reference to: https://developer.salesforce.com/forums/?id=906F000000098WiIAI
I would like a cleaner option if there is one available?