You need to sign in to do that
Don't have an account?

VERY Simple SOQL but wont work. Please help.
How do I create a string and run this simple soql query that populates it.
Example
String uRoleName = [Select u.Name From UserRole u Where u.id = : UserInfo.getUserRoleId() Limit 1];
Above doesnt work because it wants an SObject but UserRole is not an accessible sObject and I dont want an instance of it anyways I just want the one field returned into a string.
String uRoleName = [Select Name From UserRole Where Id = : UserInfo.getUserRoleId() Limit 1].Name;
All Answers
String uRoleName = [Select Name From UserRole Where Id = : UserInfo.getUserRoleId() Limit 1].Name;
You could also do it from a user query if you needed to:
String uRoleName = [Select UserRole.Name From User Where id = : UserInfo.getUserRoleId() Limit 1].UserRole.Name;