To query User Profile Name from Contact, It is Possible

Example Query Like : select Id,FirstName,LastName,(Select Id,Name,Isactive,Profile.Name from user) from Contact

Thanks Nagarjuna


Query for profiles of users

SELECT Id, Firstname, Lastname, ProfileId, Profile.Name FROM User

Query Last modified user from Contact

SELECT ID, Firstname, Lastname, LastModifiedBy.Profile.Name FROM Contact WHERE ID = :YOUR_CONTACT_ID

Query related users of contacts "Community users"

SELECT ID, ContactId, Contact.Firstname, Contact.Lastname, ProfileId, Profile.Name FROM User WHERE ContactID = :YOUR_CONTACT_ID

Try this :

  for( Contact c : [select Id,FirstName,LastName,LastModifiedBy.Name, LastModifiedBy.Profile.Name from Contact limit 1]){
System.debug('cont ' + c.FirstName + ' prof '+ c.LastModifiedBy.Profile.Name);    


  • Thanks AtulRajguru,i tried above query i am getting Id,FirstName,LastName,LastModifiedBy.Name but i am not getting LastModifiedBy.Profile.Name and i also no need LastModifiedBy.Profile.Name because daily schedule bacth will excecute that time Admin User comes on LastModifiedBy – nagarjuna May 23 '14 at 7:23
  • @user4812 LastModifiedBy is used as example. you can change it to owner on any other field of your interest (which is referring to users table) – AtulRajguru9 May 23 '14 at 8:02
  • Updated my query with code that print Contact Name And Profile name – AtulRajguru9 May 23 '14 at 8:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.