0

This is a case in Salesforce: There is a lookup relationship from Account to Individual, both standard objects. How to write a parent-to-child SOQL query where Individual is the parent and Account is the child?

When I try the code below:

SELECT Id, (SELECT Id FROM Accounts) FROM Individual 

I get this error:

ERROR at Row:1:Column:28 Didn't understand relationship 'Accounts' in FROM part of query call. 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.

Do you know how to fix this? Thanks

1 Answer 1

0

There is no way to query the child accounts of an individual. Salesforce does not provide that ability for this particular relationship.

(In general, you can find the relationship name as follows:

To find the relationship name for a SOQL query, go to Setup → Object Manager → Account → Fields & Relationships and find the lookup to Individual. Look for the Child Relationship Name under Lookup Options or Field Information. This is the name you use when querying child accounts from the Individual object.

If the lookup field is a custom field, you'll need to add __r to the end of this.)

2
  • I don't see that when opening the field lookup to individual
    – Gnopor
    Feb 23 at 16:47
  • 1
    Looks like Salesforce hasn't given it a relationship name so it's not possible to query it like this
    – fred
    Feb 23 at 17:53

You must log in to answer this question.

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