You need to sign in to do that
Don't have an account?
Creating a related list from 2 unrelated Objects (and a junction Object)
I have two Objects (Deal__c and Property__c) that I would like to join in a related list. Deal and Property are not related to each other but they do have a junction object Deal_Property__c (Deal is the master of Deal Property, and Deal Property has Property as a lookup field). I want to create a controller extension that for Deal A lists Properties 1, 2 and 3. I think this is possible but I cannot come up with the correct syntax. I've searched the documentation and Trailhead, but cannot quite find what I am looking for. Any ideas? Thanks.
SELECT Name, Id,
(SELECT Property__c, Property__r.Name, Property__r.Asset_Type__c, Property__r.Portfolio__c, Property__r.Campus_Type__c, Property__r.Market__r.Name
FROM Deal_Properties__r)
FROM Deal__c
WHERE Id = 'a06o000000EaLsT'
BIG thanks to David Liu and his "Apex Academy" for providing the framework for the solution.
All Answers
Select Name, Asset_Type__c, Portfolio__c, Campus_Type__c, Market__r.name FROM Property__c Where Deal_r.Id= Deal_to_Link__c
This query is throwing an "Unknown error". No sure what i am missing.
SELECT Name, Id,
(SELECT Property__c, Property__r.Name, Property__r.Asset_Type__c, Property__r.Portfolio__c, Property__r.Campus_Type__c, Property__r.Market__r.Name
FROM Deal_Properties__r)
FROM Deal__c
WHERE Id = 'a06o000000EaLsT'
BIG thanks to David Liu and his "Apex Academy" for providing the framework for the solution.