Pages

Thursday, January 07, 2016

Salesforce Identify Current Users UI mode theme : Classic or Lightning Experience or Salesforce1 mobile

Now with Spring 16 release, Developers and Admins can easily identify the current user's Salesforce user interface mode or theme - i.e if the running user is using Salesforce Classic UI or the new Lightning Experience in desktop or if the user is in Salesforce1 mobile.

We now have new set of values included in the existing User Context Global variables (both $User in workflows/validations/visualforce/formulas and also to the UserInfo class in Apex)

with this, we can simply call either UserInfo.getUiTheme( ) method or $User.UiTheme variable to identify the running user's UI mode.



here's the list of UI Themes returned by this global variable
  • Theme1—Obsolete Salesforce theme
  • Theme2Salesforce Classic 2005 user interface theme
  • Theme3Salesforce Classic 2010 user interface theme
  • Theme4d—Modern “Lightning Experience” Salesforce theme
  • Theme4tSalesforce1 mobile Salesforce theme
  • PortalDefaultSalesforce Customer Portal theme
  • WebstoreSalesforce AppExchange theme

Reference :
You will find this cool feature documented (buried) deep inside the Spring 16 release notes

No comments: