function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Bart DewveallBart Dewveall 

SOQL query using Lookup relationship fields.

Hello, I have a custom object with three lookup fields, one to User one to Contact and one to Account. I'm executing the following query but it complains about the relationship in getting the name from the User object. If I exclude User__r.Name from the query It returns the Contact and Account Names OK. Any help would be appreciated.

SELECT User__r.Name, Number_Tickets_Requested__c, Contact__r.Name, Account__r.Name FROM SFL1_Ticket_Req__c
 
Head In CloudHead In Cloud
Hi, Can you please check the API name for the user lookup field you created. Is it User__c ? or if you are trying to get the owner name of standard field, then you should use owner.name in your query
Rahul BoinepallyRahul Boinepally
Adding to Head In Cloud's answer - just check your access to user object if you have read access. 
Bart DewveallBart Dewveall
The API name of the Lookup to user object is Requester__c.