0

I have Accounts and InteractionsReferences.

Trying to query something like this (formatted because I'm using GET query:

SELECT+Account.Name+,(SELECT+Interaction_References__r.Id+FROM+Interaction_References__r)+FROM+Account+ORDER+BY+CreatedDate+DESC+LIMIT+10

But I get the following error:

{
    "message": "\nInteraction_References__r.Id FROM Interaction_References__r) FROM ERROR at Row:1:Column:64 Didn't understand relationship 'Interaction_References__r' 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.",
    "errorCode": "INVALID_TYPE"
}

However, when looking at the field in Salesforce, I see this, which makes it seem like I am calling it the right way:

child relationship name

Any help is appreciated!

1 Answer 1

1

Within each SELECT, you reference the field relative to the FROM object. In other words, it should just be Id (presumably); the same is true for Account.Name, it should just be Name. Also, if this is a managed field, you may need to prefix the relationship name with the namespace:

SELECT Name,
  (SELECT Id FROM AIM__Interaction_References__r) 
FROM Account ORDER BY CreatedDate DESC LIMIT 10

The primary use for the __r.Field convention is when you're going from child to parent records:

SELECT AIM__Account__r.Name
FROM AIM__Account__c

You must log in to answer this question.

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