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.
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.