How to get the profile name and role name from User object

2.0K    Asked by amit_2689 in Salesforce , Asked on Apr 24, 2021

We already have a soql query to retrieve the User object (which returns the role id and profile id) was wondering if we could retrieve the RoleName and ProfileName from within the same query instead of making an additional query to the userInfo object. It will be of great help if you could please point us in the right direction

Note: Also we want to retrieve this for a seq of users so it would save a lot of additional calls if we could retrieve those details in the same call for the User object. How to get the profile name?


Answered by Aswini Lobo

You can retrieve profile name, role name this way:

select id, name, , profile.name, userrole.name from user

For details on how this works, you can refer to the Name object's documentation.



Your Answer

Interviews

Parent Categories