1

I have the following situation

  • Object MortgageApplication: has a lookup field called PrimaryLoanApplicant. The lookup is against Object Loan Applicant. The child relationship name is called LA
  • Object Loan Applicant: Has a look up field called contactid. The lookup is against Contact object. The child relationship name is called CLA

I am trying to get the Applicants name from the Contact object along with some other fields/details from Mortgage Application object.

MortgageApplication ma = [SELECT Id, Name, Status, (SELECT contactid__r.name from la__r), Amount_of_Funding_Required__c
        FROM MortgageApplication
        WHERE Id =:sbaId]

When I write the following, I get 'Didn't understand relationship __r error'.

I am getting this terribly wrong. Can someone give me a tip on how to get this query working?

Thanks

1 Answer 1

3

You shouldn't use child relationship query because your LoanApplicant object is a parent of MortgageApplication object. Simply use the dot notation.

For example: If your lookup field to the LoanApplicant object is La__c:

MortgageApplication ma = [SELECT Id, Name, Status, la__r.contactid__r.name, Amount_of_Funding_Required__c
        FROM MortgageApplication
        WHERE Id =:sbaId]
1
  • Thanks a lot for the tip. I get it. It did resolve the issue. Big thanks.
    – d039043
    May 21, 2020 at 13:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .