UserInfo Methods

The following are the system static methods for UserInfo.

Name Arguments Return Type Description
getDefaultCurrency String Returns the context user's default currency code for multiple currency organizations or the organization's currency code for single currency organizations.
Note
For Apex saved using Salesforce.com API version 22.0 or earlier, getDefaultCurrency returns null for single currency organizations.
getFirstName String Returns the context user's first name
getLanguage String Returns the context user's language
getLastName String Returns the context user's last name
getLocale String Returns the context user's locale. For example:
String result = UserInfo.getLocale();
System.assertEquals('en_US', result);
getName String Returns the context user's full name. The format of the name depends on the language preferences specified for the organization. The format is one of the following:
  • FirstName LastName
  • LastName, FirstName
getOrganizationId String Returns the context organization's ID
getOrganizationName String Returns the context organization's company name
getProfileId String Returns the context user's profile ID
getSessionId String Returns the session ID for the current session.

For Apex code that is executed asynchronously, such as @future methods, Batch Apex jobs, or scheduled Apex jobs, getSessionId returns null.

As a best practice, ensure that your code handles both cases – when a session ID is or is not available.

getTimeZone System.TimeZone Returns the current user’s local time zone.

Example:

TimeZone tz = 
  UserInfo.getTimeZone();
System.debug(
  'Display name: ' + 
  tz.getDisplayName());
System.debug(
  'ID: ' + 
  tz.getID());
getUiTheme String Returns the default organization theme. Use getUiThemeDisplayed to determine the theme actually displayed to the current user.
Valid values are:
  • Theme1
  • Theme2
  • PortalDefault
  • Webstore
getUiThemeDisplayed String Returns the theme being displayed for the current user.
Valid values are:
  • Theme1
  • Theme2
  • PortalDefault
  • Webstore
getUserEmail String Returns the current user’s email address.

Example:

String emailAddress = 
  UserInfo.getUserEmail();
System.debug(
  'Email address: ' + 
  emailAddress);
getUserId String Returns the context user's ID
getUserName String Returns the context user's login name
getUserRoleId String Returns the context user's role ID
getUserType String Returns the context user's type
isCurrentUserLicensed String namespace Boolean Returns true if the context user has a license to the managed package denoted by namespace. Otherwise, returns false.

A TypeException is thrown if namespace is an invalid parameter.

isMultiCurrencyOrganization Boolean Specifies whether the organization uses multiple currencies
© Copyright 2000–2013 salesforce.com, inc. All rights reserved.
Various trademarks held by their respective owners.