You need to sign in to do that
Don't have an account?
Uday Menkurkar
Unable to get Custom Object List Extension Controller working
Question for VF/Apex experts.
I'm unable to load child records from a master-detail relationship using Apex and Visualforce. Here is my setup. I've Master-Detail relationship between PP_Deals__c (Master object) and Tranche__c (Child object). My goal is to display parent-child records meeting certain criteria using VF page and a custom list controller. My sample VF page and Apex extension controller is below. The problem is that I can see the parent records but no child records. If I remove the WHERE clause in the query, I can see all the records. Also, if I put a specific parent id in the parent clause I can see records, but in its current form it I don't see child records when in principal the WHERE clause should have the correct id. What am I missing?
Thanks in advance for help.
<!-- Visualforce code -->
<apex:page standardController="PP_Deals__c" recordSetVar="deals" extensions="extCon">
<apex:pageBlock >
<apex:pageBlockTable value="{! deals }" var="ds">
<apex:column value="{! ds.Name }"/>
<apex:column value="{! ds.id }"/>
<apex:column >
<apex:pageBlock >
<apex:pageBlockTable value="{! relatedTranches}" var="val">
<apex:column value="{! val.name}"/>
<apex:column value="{! val.Id}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:page>
// Associated Apex Code -- Controller List extension
public class extCon {
private final PP_Deals__c deal;
public extCon(ApexPages.StandardSetController controller) {
deal = (PP_Deals__c) controller.getRecord();
}
public List<Tranche__c> getrelatedTranches()
{
List <Tranche__c> conList = New List<Tranche__c>();
for(PP_Deals__c acc:[ SELECT id,name, (SELECT id, name FROM Tranches__r) FROM PP_Deals__c WHERE id = :deal.id ])
{
for(Tranche__c con:acc.Tranches__r)
conList.add(con);
}
return conList;
}
}
I'm unable to load child records from a master-detail relationship using Apex and Visualforce. Here is my setup. I've Master-Detail relationship between PP_Deals__c (Master object) and Tranche__c (Child object). My goal is to display parent-child records meeting certain criteria using VF page and a custom list controller. My sample VF page and Apex extension controller is below. The problem is that I can see the parent records but no child records. If I remove the WHERE clause in the query, I can see all the records. Also, if I put a specific parent id in the parent clause I can see records, but in its current form it I don't see child records when in principal the WHERE clause should have the correct id. What am I missing?
Thanks in advance for help.
<!-- Visualforce code -->
<apex:page standardController="PP_Deals__c" recordSetVar="deals" extensions="extCon">
<apex:pageBlock >
<apex:pageBlockTable value="{! deals }" var="ds">
<apex:column value="{! ds.Name }"/>
<apex:column value="{! ds.id }"/>
<apex:column >
<apex:pageBlock >
<apex:pageBlockTable value="{! relatedTranches}" var="val">
<apex:column value="{! val.name}"/>
<apex:column value="{! val.Id}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:page>
// Associated Apex Code -- Controller List extension
public class extCon {
private final PP_Deals__c deal;
public extCon(ApexPages.StandardSetController controller) {
deal = (PP_Deals__c) controller.getRecord();
}
public List<Tranche__c> getrelatedTranches()
{
List <Tranche__c> conList = New List<Tranche__c>();
for(PP_Deals__c acc:[ SELECT id,name, (SELECT id, name FROM Tranches__r) FROM PP_Deals__c WHERE id = :deal.id ])
{
for(Tranche__c con:acc.Tranches__r)
conList.add(con);
}
return conList;
}
}
Let us know if this will help you
All Answers
Let us know if this will help you