get ownerid - Answers - Salesforce Trailblazer Community
Trailblazer Community
Ask Search:
Sai AkhilSai Akhil 

get ownerid

hi
I have a custom object payment__c
i want to get email of ownerId of a record in payment__c in apex
 
Best Answer chosen by Sai Akhil
Ronald DefeoRonald Defeo
Is Payment__c a child in a Master-Detail Relationship? If yes, you the PARENTFIELD.Owner.Email. 
 
SELECT Id, Battle_Station__r.Owner.Email FROM Resource__c
The query is just an example as a guide on how to accomplish this.

All Answers

Ronald DefeoRonald Defeo
Hi Sai,

You can use  this query.
 
​​​​​​​SELECT Id, Owner.Email FROM Payment__c
Sai AkhilSai Akhil
i already tried this i am getting an error
Didn't understand relationship 'Owner' in field path. If you are attempting to use a custom relationship, be sure to append the '__r' 
Ronald DefeoRonald Defeo
Is Payment__c a child in a Master-Detail Relationship? If yes, you the PARENTFIELD.Owner.Email. 
 
SELECT Id, Battle_Station__r.Owner.Email FROM Resource__c
The query is just an example as a guide on how to accomplish this.
This was selected as the best answer