
I need to use logged-in user's role name in the if clause in a APEX code, something like if (loginuserole != "ABC")
{
line1 ;
line2l;
}
Any input on how to get user role to use in above code?
3 件の回答
Nagendra, You could use something like this (roleName would return the current logged in user's Role Name):
Id userRoleId = userinfo.getUserRoleId();
String roleName = [SELECT Id, Name
FROM UserRole WHERE Id=:userRoleId].Name;
System.debug(roleName);
For any further questions related to this, I would highly recommend posting on the developer forums since this community is focused on help with configuration changes and non-programmatic solutions.
- StackExchange [http://salesforce.stackexchange.com]
- Official Developer Forum [https://developer.salesforce.com/forums]
For any configuration changes and point and click design solutions, feel free to post in this community and we will be glad to help you out.