Identify Salesforce User Experience Theme in Apex Class
We can use UserInfo.UITheme() and UserInfo.UIThemeDisplayed() in Apex class to determine User Experience Theme.
UserInfo.UITheme() : Returns the theme that is supposed to be used.
UserInfo.UIThemeDisplayed() : Returns the theme that is actually being used.
UserInfo.UITheme() and UserInfo.UIThemeDisplayed() will return following values.
- Theme1—Obsolete Salesforce theme
- Theme2—Salesforce Classic 2005 user interface theme
- Theme3—Salesforce Classic 2010 user interface theme
- Theme4d—Modern “Lightning Experience” Salesforce theme
- Theme4t—Salesforce mobile app theme
- Theme4u—Lightning Console theme
- PortalDefault—Salesforce Customer Portal theme
- Webstore—Salesforce AppExchange theme
Sample Code:
String themeDisplayedType = UserInfo.getUIThemeDisplayed(); String themeType = UserInfo.getUITheme();