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
Rohit Thakur 19Rohit Thakur 19 

Is there any way to get lead owner createdbyid on lead in SOQL

Is there any way to get owner.createdbyid on lead in SOQL

I just need lead Owner Created by id in lead through SOQL. compare both the below SOQL. 

Select id,owner.createdbyid, CreatedById, createdby.name from Lead. 
Error: No such column 'createdbyid' on entity 'Name'. 

Select id,owner.createdbyid, CreatedById, createdby.name from Account. 
Working Fine

Thanks 
Rohit Thakur

 
Best Answer chosen by Rohit Thakur 19
David Zhu 🔥David Zhu 🔥
you may need two soql querys to get owner.createdbyid on Lead record.

Lead l = [select id,ownerid from Lead where id = 'xxxxx'];
User u = [Select createdbyid from user where id = l.ownerid];