function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Prakash@SFDCPrakash@SFDC 

How can we query Parent's Lookup Object fileds from Child Object

Hi,

 

I have a requirement like query the  child object and throught this query we have to get the values of another object which is a lookup to its parent. In this case PartnerLocation is the Child to Account and Opportunity is the Lookup to Account.

 

Thanks in Advance

Prakash.N

Tony P.ax1100Tony P.ax1100

The easiest way would be to query the Account object from PartnerLocation then do another query from Opportunity with your Account in the WHERE clause.  This could return multiple Opportunities, so you'll need some other criteria to pick the right one.

Prakash@SFDCPrakash@SFDC

Hi Tony  thanks for your reply,

 

Can we write it as a  single query (inner query) ?i  Because i need to pass the result to Java Script function in the VF page .

I am giving some sample code below....

 

SELECT Account.Id, Amount, Name, Account.Account_Subtype_M__c, StageName,  Primary_Technology__c,( select Account.Latitude__c, Account.Longitude__c from Opportunity.Account.Partner_Locations__r Limit 1), Account.BillingStreet, Account.BillingCity, Account.BillingCountry FROM Opportunity.

 

I am not sure whether it is correct or not . In this i am quering oppurtunity in which i am including an innerquery on child through Account.

 

 

Prakash