The following are methods for UserInfo. All methods are static.
public static String getDefaultCurrency()
Type: String
public static String getFirstName()
Type: String
public static String getLanguage()
Type: String
public static String getLastName()
Type: String
public static String getLocale()
Type: String
String result = UserInfo.getLocale(); System.assertEquals('en_US', result);
public static String getName()
Type: String
The format is one of the following:
public static String getOrganizationId()
Type: String
public static String getOrganizationName()
Type: String
public static String getProfileId()
Type: String
public static String getSessionId()
Type: String
You can use getSessionId() both synchronously and asynchronously. In asynchronous Apex (Batch, Future, Queueable, or Scheduled Apex), this method returns the session ID only when the code is run by an active, valid user. When the code is run by an internal user, such as the automated process user or a proxy user, the method returns null.
As a best practice, ensure that your code handles both cases: when a session ID is or is not available.
public static System.TimeZone getTimeZone()
Type: System.TimeZone
TimeZone tz = UserInfo.getTimeZone(); System.debug( 'Display name: ' + tz.getDisplayName()); System.debug( 'ID: ' + tz.getID());
public static String getUiTheme()
Type: String
The preferred theme for the current user.
public static String getUiThemeDisplayed()
Type: String
The theme being displayed for the current user
public static String getUserEmail()
Type: String
String emailAddress = UserInfo.getUserEmail(); System.debug( 'Email address: ' + emailAddress);
public static String getUserName()
Type: String
public static String getUserRoleId()
Type: String
public static String getUserType()
Type: String
public static Boolean isCurrentUserLicensedForPackage(ID packageID)
Type: Boolean
Retrieve packageIDat runtime, with the getCurrentPackageId() method. Then, use packageId to confirm that the contextual user is licensed to use that managed package.
A TypeException is thrown if packageID is an invalid type. A SystemException is thrown if packageID is the ID of an unlocked or unmanaged package, or if the contextual user doesn’t have a license to the managed package.
public static Boolean isMultiCurrencyOrganization()
Type: Boolean