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
Jennifer.SchnellJennifer.Schnell 

How do I query for the name and UserRole.Id?

How do I query for the name of role and UserRole.Id for the org using Developer Console?
Best Answer chosen by Jennifer.Schnell
Raj VakatiRaj Vakati
Below one is fine. No need to add any more. 
 
Select  UserRole.Name from user

Even you can use below one to see username and role on the same row 
 
Select  UserName , UserRole.Name from user

All Answers

Raj VakatiRaj Vakati
Select Id ,UserName, UserRole.Name from user

 
Jennifer.SchnellJennifer.Schnell
Thanks @Raj.  Did you mean to put
Select Id ,UserName, UserRole.ID from user?  Neither one works, do I have to specify a specific user? I am looking to return the Name and ID of all the roles we have defined in our org.
Raj VakatiRaj Vakati
Below one is fine. No need to add any more. 
 
Select  UserRole.Name from user

Even you can use below one to see username and role on the same row 
 
Select  UserName , UserRole.Name from user
This was selected as the best answer
Jennifer.SchnellJennifer.Schnell
When I use the below in the dev console, I receive an error - "No such relation 'UserRole' on entity 'User'. 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."

 
Select  UserRole.Name from user

 
Raj VakatiRaj Vakati
Hi Jennifer, 

Its Standard filed.Pls refer this image below 

User-added image
 
Jennifer.SchnellJennifer.Schnell
I see what I did wrong, "Use Tooling API" was checked.  What is that used for?
 
Raj VakatiRaj Vakati
 Tooling API to build custom development tools on your own.  Please mark it as solved. 
Refer this link 

https://developer.salesforce.com/docs/atlas.en-us.api_tooling.meta/api_tooling/intro_api_tooling.htm