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 owner.createdbyid on lead in SOQL

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

 
Marzorati ClaudioMarzorati Claudio
Your query is not correct.
Try this one
SELECT Id, CreatedById, Name FROM Lead

Claudio
VinayVinay (Salesforce Developers) 
Hi Rohit,

Try below query.
SELECT Id, OwnerId , CreatedById FROM Lead

You cannot use 'owner.createdbyid' in your query try to check available fields in workbench.

Hope above information was helpful.

Please mark as Best Answer so that it can help others in the future.

Thanks,
Vinay Kumar
Rohit Thakur 19Rohit Thakur 19
Hi Marzorati Claudio and Vinay,

Can you please compare both the SOQL. I just need lead Owner Created by id in lead throug SOQL.
Is there any way to get owner.createdbyid on lead in 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
Marzorati ClaudioMarzorati Claudio
Hi Rohit,

it depends on your need.

If you want only the record owner and who create it, you can simply use:
 
SELECT OwnerId, CreateById FROM Lead

or best this
 
SELECT OwnerId, Owner.Name, CreateById, CreateBy.Name FROM Lead

This query
Select id,owner.createdbyid, CreatedById, createdby.name from Lead
don't work on Lead because Lead is particular object and for me the Owner is a particular instance "License Management App".

Use this for example
Select id,owner.name, CreatedById, createdby.name from Lead

In other objects this query works fine, but always remember to focus on your need.

Claudio