I have two objects
Request__c and Matter__c
These two objects have a lookup relationship where Request__c is a lookup field on Matter__c. So a single Request record can have multiple Matter records.
I’m trying to write a SOQL query on the Request to pull all Matters associated with each Request. My query is as follows:
SELECT Id, Name, (SELECT Id, Status__c, Matter_Type__c FROM Matters__r) FROM Request__c
But whenever I try running this I get the following error:
Didn't understand relationship 'Matters__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.
I thought that if there was a lookup field on the Matter__c object, then a relationship between the 2 objects would exist and I could query to pull all the children (Matters) for a given Request.
I’ve checked the field in Setup -> Create -> Objects -> Matter__c and it provides the following information:
Related List Label: Matters
Child Relationship Name: Request
Can someone help me sort this out?
Matters
is a child ofRequest__c
, the child relationship nameRequest
is a poor choice and now would be the time to change it toMatters
before you bake it into Apex code.