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
lokesh reddy 7lokesh reddy 7 

how to get the user details from lead object

Hi ,

How to get the user field details from the lead object .
 

Thanks
lokesh

RohRoh
Hello Lokesh,
Please use the created By field on the lead object to get the User details.

Please mark this as the best answer if you liked it.

Thanks,
Rohit Alladi
Anupama SamantroyAnupama Samantroy
Hi Lokesh,

There are various standard user fields on the Lead object.
CreatedBy
LastModifiedBy
OwnerId

You can query these fields for the user details you can access all fields of the user object if you have necessary permissions.
Select Owner.Name, CreatedBy.Name, LastModifiedBy.Name from Lead

Thanks
Anupama
lokesh reddy 7lokesh reddy 7
Hi Roh,

If i use created By field then if the lead owner changes then the lead owner will be different and created by id is different.I need to get the custom field on the user object depending upon the lead owner and use in condition.

thanks
lokesh
RohRoh
Hello Lokesh,
Sure , we can also do it a way where you could get the fields from the Lead Owner Field (Owner.Id , Owner.Name) etc..

Try this out.

Please select this as the best answer if you like it.

Thanks,
Rohit Alladi
lokesh reddy 7lokesh reddy 7
Hi Rohit,
I am trying to use the below query but not sure why iam getting the error:

select id,name,owner.Designation__c from lead
Error:
No such column 'Designation__c' on entity 'Name'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names
 
RohRoh
Hello Lokesh,
Yes , in that case we need to use the Left Inner Join Query as below ,

SELECT Name,Designation__c from User where id IN (Select ownerId from Lead) .

Please select this as the best answer if you like it.

Thanks,
Rohit Alladi