I've got 3 objects => -Object A has a lookup with Object B (Order) -Obect C (case) has a lookup with Object B
I need to retreive a field on Object C to display with all the field from the Object A (with SOQL) in Visualforcepage. Any ideas ? :)
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It only takes a minute to sign up.
Sign up to join this communityYou'd use two subqueries:
SELECT
(SELECT Id FROM A__r),
(SELECT Id FROM C__r)
FROM B__c
WHERE Id IN (SELECT B__c FROM A__c WHERE Id = :aRecordId)
If you're using pure Visualforce without Apex, you need to have B's ID, instead:
<apex:page standardController="B__c">
<apex:repeat value="{!B__c.A__r}" var="a">
{!a.Name}
</apex:repeat>
<apex:repeat value="{!B__c.C__r}" var="c">
{!c.Subject}
</apex:repeat>
</apex:page>