0

select Name,UltimateMotherKIS__c,contract__r.Name FROM Account ^ ERROR at Row:1:Column:34 Didn't understand relationship 'contract__r' in the field path. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names.

0

There is a stranger relationship between Account and Contracts, It also took me for a while to understand. Please try to go for Inner query rather than using __r.Hopefully it will help.

0

Account has a one to many relationship with Contracts i.e. one account can have multiple contracts. Dot (.) operator is used when you want to get the parent field from child object. When you want to get the child records from parent object, you should use sub query (SOQL query) to get related childs of parent. In your case, to get related Contracts of Account object.

Your SOQL query should be

select Id, Name, UltimateMotherKIS__c,(Select Id, Name from Contract) FROM Account

where Contract is the child relationship name. From this SOQL query, you will get all the Accounts with its associated Contracts. This SOQL will return List<Account> and each Account record will have associated List<Contract> within it. Post getting the records from SOQL, you should have the logic to pick suitable Contract records from each Account record.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.