I have a custom object (Registration__c) that has a lookup field (Approver__c) to the standard User object.

I'm trying to construct an SOQL query that will return the user's ID.

My assumption is that since it's a child to parent relationship, the query should be:

SELECT Id, Approver__r.Id
FROM Registration__c

However, running the above query results in "No such relation 'Approver__r' on entity 'Registration__c'."

What am I missing?


Query using 'Approver__c' returns "No such column 'Approver__c' on entity 'Registration__c'."

SELECT Id, Approver__c
FROM Registration__c

Here's a couple of screenshots showing the custom object (Registration__c) and custom field (Approver__c):

Registration__c custom object enter image description here



  • Are you sure that you don't have a typo out there somewhere? Also, you can get the Id with simply doing Approver__c, if that is the field name May 22 '20 at 16:13
  • Thanks @SebastianKessel! I don't see anything obvious in terms of typos. I added a couple of screenshots that show the object and field. Using the Approver__c returns a similar error message. Thoughts? May 22 '20 at 16:22
  • Does your user have access to the field? How are you doing the query? Apex or Dev Console? May 22 '20 at 16:22
  • 1
    @SebastianKessel That was the answer! The user did not have access to the field. Changing the field accessibility settings fixed the error. Thank you so much : ) Did you want to submit your answer and I'll accept it? May 22 '20 at 16:30
  • Done, glad to have been able to help! May 22 '20 at 16:31

If the field exists, and it is spelled properly, it is likely a permissions problem with the user running the query.

Also, if you wish to just get the Id of the related record, you can just do Approver__c instead of Approver__r.Id for simplicity.

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.