3

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

2 Answers 2

3

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
1

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);    

}

3
  • 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
    Commented May 23, 2014 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) Commented May 23, 2014 at 8:02
  • Updated my query with code that print Contact Name And Profile name Commented May 23, 2014 at 8:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .