You need to sign in to do that
Don't have an account?
Admin User 10568
Apex Class Child to Parent SOQL for Page Block Table
Hi,
Hoping someone could help me out.
I have the following apex class:
public class PriceListAscending{
private String sortOrder = 'REPRO__Project_Name__c';
public list<REPRO__Project__c> getEvents() {
list<REPRO__Project__c> results = Database.query(
' SELECT REPRO__Project_Name__c, REPRO__Properties__r.REPRO__Property__c, REPRO__Properties__r.REPRO__City__c, REPRO__Properties__r.Property_Level__c, REPRO__Properties__r.Price_List_Property_Name__c, REPRO__Properties__r.REPRO__Type__c,REPRO__Properties__r.REPRO__Bdr__c,REPRO__Properties__r.REPRO__Bth__c,REPRO__Properties__r.REPRO__Study__c,REPRO__Properties__r.REPRO__Internal_Size__c,REPRO__Properties__r.REPRO__External_Size__c, REPRO__Properties_r.REPRO__Car_c, REPRO__Properties__r.REPRO__List_Price__c, REPRO__Properties__r.REPRO__Status_c ' +
' FROM REPRO__Project__c' +
' ORDER BY ' + sortOrder + ' ASC '
);
return results;
}
}
There is no error displayed in the editor.
When I try to call the fields from a pageblocktable for my visual page, I get the following error: Invalid field Property_Level__c for SObject REPRO__Project__c
Here is an example of the call:
<apex:pageBlockTable value="{!Events}" var="e" align="center" cellpadding="2" border="4" style=" font-weight: bold; text-align: center" >
<apex:column value="{!e.Property_Level__c}" style="padding: 10px;order-bottom: 1px solid #ddd;border: 1px solid black; text-align: center; " />
Any help would be greatly appreciated.
Hoping someone could help me out.
I have the following apex class:
public class PriceListAscending{
private String sortOrder = 'REPRO__Project_Name__c';
public list<REPRO__Project__c> getEvents() {
list<REPRO__Project__c> results = Database.query(
' SELECT REPRO__Project_Name__c, REPRO__Properties__r.REPRO__Property__c, REPRO__Properties__r.REPRO__City__c, REPRO__Properties__r.Property_Level__c, REPRO__Properties__r.Price_List_Property_Name__c, REPRO__Properties__r.REPRO__Type__c,REPRO__Properties__r.REPRO__Bdr__c,REPRO__Properties__r.REPRO__Bth__c,REPRO__Properties__r.REPRO__Study__c,REPRO__Properties__r.REPRO__Internal_Size__c,REPRO__Properties__r.REPRO__External_Size__c, REPRO__Properties_r.REPRO__Car_c, REPRO__Properties__r.REPRO__List_Price__c, REPRO__Properties__r.REPRO__Status_c ' +
' FROM REPRO__Project__c' +
' ORDER BY ' + sortOrder + ' ASC '
);
return results;
}
}
There is no error displayed in the editor.
When I try to call the fields from a pageblocktable for my visual page, I get the following error: Invalid field Property_Level__c for SObject REPRO__Project__c
Here is an example of the call:
<apex:pageBlockTable value="{!Events}" var="e" align="center" cellpadding="2" border="4" style=" font-weight: bold; text-align: center" >
<apex:column value="{!e.Property_Level__c}" style="padding: 10px;order-bottom: 1px solid #ddd;border: 1px solid black; text-align: center; " />
Any help would be greatly appreciated.
See example below
Traverse multiple level upwards
There is a custom lookup field on contact object called Best Friend and there is a field called likes ice cream. Write a query to retrieve the custom field
Here we’re traversing a custom lookup field Best_Friend__c on the contact object. Notice how the “__c” changes to a “__r” when traversing that field!
All Answers
See example below
Traverse multiple level upwards
There is a custom lookup field on contact object called Best Friend and there is a field called likes ice cream. Write a query to retrieve the custom field
Here we’re traversing a custom lookup field Best_Friend__c on the contact object. Notice how the “__c” changes to a “__r” when traversing that field!
Thanks for your help. Much appreciated.
Yes there is: REPRO__Properties__r.Property_Level__c
Since posting my earlier question. I tested the following in the Query Editor:
SELECT (select Property_Level__c from REPRO__Properties__r) FROM REPRO__Project__c
This returned the expected results.
But the following:
Select REPRO__Properties__r.Property_Level__c from REPRO__Project__c
No dice.
Any thoughts on why my dot notation hasn't traversed correctly here?