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

Accessing current user Role



I want to check Current logged user's role with values of a Multi-picklist field in the Apex ?

can anyone tell me idea to do? Thanks...




You can get the User's Role directly by using this syntax:


String uRoleId = UserInfo.getUserRoleId();

 And you can additionally query the UserRole object to get the Role Name, if needed.


Are you then asking how to see if the Role Name is in a multi-select field value?

The multi-select field should be a semi-colon seperated list of strings. So you could try to split that field value in a String[] using the String class, and check to see if the Role Name value exists. 


Thanks aalbert....
Sandeep JainSandeep Jain


We are trying to populate user and user role object. I am really not clear with user role object. What is the use of this table on SFDC side? Can we customized this table?



Sandeep Jain