You need to sign in to do that
Don't have an account?
Girinoob
How to display subquery value in visualforce page
Hi,
I have master detail relationship with contact and custom object BroadBandCustomers .
So, i have used a subquery to fetch few details from custom object . i would like to know how to display sub query value in visualforce page . I am getting values .... tested in workbench.
Here is my query:
SELECT Homeroom__c ,Phone ,Number_of_calls__c ,
(SELECT id FROM BroadBandCustomers__r ORDER BY HSI_Stage_Date__c)
FROM Contact ORDER BY LastName, FirstName
Hi,
I wish this will help you.
List<Contact> c = [SELECT Homeroom__c ,Phone ,Number_of_calls__c ,(SELECT id FROM BroadBandCustomers__r ORDER BY HSI_Stage_Date__c) FROM Contact ORDER BY LastName, FirstName];
Now you have a list of contact . Now make a map because each contact may have more than one broadbandcustomers. A map contain id of each contact respective list of bbcustomer
Map<String,List<BroadBandCustomer__c>> mapC = new Map<String,List<BroadBandCustomer__c>>()
for(Contact x : c){
mapC.add(c.id, c.BroadBandCustomers__r);
}
<apex:repeat value="{!C}" var="M">
<apex:repeat value="{!MyMap[M.id]}" var="temp">
<apex:outputLabel value="{!temp.id}"/>
</apex:repeat>
</apex:repeat>
/* If answered Mark as solved it might help someone in need */
All Answers
Use Contact.BroadBandCustomers__c in value attribute.
It says invalid field name in contact object when i use contact.BroadBandCustomers__c
Hi,
I wish this will help you.
List<Contact> c = [SELECT Homeroom__c ,Phone ,Number_of_calls__c ,(SELECT id FROM BroadBandCustomers__r ORDER BY HSI_Stage_Date__c) FROM Contact ORDER BY LastName, FirstName];
Now you have a list of contact . Now make a map because each contact may have more than one broadbandcustomers. A map contain id of each contact respective list of bbcustomer
Map<String,List<BroadBandCustomer__c>> mapC = new Map<String,List<BroadBandCustomer__c>>()
for(Contact x : c){
mapC.add(c.id, c.BroadBandCustomers__r);
}
<apex:repeat value="{!C}" var="M">
<apex:repeat value="{!MyMap[M.id]}" var="temp">
<apex:outputLabel value="{!temp.id}"/>
</apex:repeat>
</apex:repeat>
/* If answered Mark as solved it might help someone in need */
list<Contact> mylist = [SELECT Homeroom__c ,Phone ,Number_of_calls__c ,
(SELECT id FROM BroadBandCustomers__r ORDER BY HSI_Stage_Date__c)
FROM Contact ORDER BY LastName, FirstName]
<apex:repeat value="{!mylist}" var="con" >
<apex:repeat value="{!con.BroadBandCustomers__r}" var="temp" >
<apex:outputField value="{!temp.FieldName}" />
....
</apex:repeat>
</apex:repeat>