Total Pageviews

Wednesday, December 26, 2018

Look and Feel aka Themes & Their Detection in Salesforce



Now a days we all invariably or mostly are using the Lightning Experience theme. Of late there are quite a variety of themes in Salesforce , have you ever felt the need to know the theme which is currently being applied when a page renders. You might say, big deal I know the theme I have applied to my pages so why bother. Well as per the documentation of Salesforce and many practical experiences , the rendered Theme may not be the same as the theme applied to the page and its guided by the browser being used and the final outcome is decided not by "preference and permission" but the ability of the browser to support the selected Theme. It is necessary that I mention the term "user interface context" for clarity on this topic , its nothing but the technical term for UI rendered. Also w.r.t. U. I. C. ("user interface context") it's vital to understand the difference between the user interface context requested by the user, and the user interface context the user is actually in. The former is guided by preference and permission applied and the later is the view which is actually rendered. Salesforce has the following themes in its kitty as of now :-
  • 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


At this juncture its important that 2 sets of variables/ methods are introduced :-
  1. $User.UITheme in VF Pages gives the value of applied theme / UserInfo.getUiTheme() in Apex gives the value of applied theme
  2. $User.UIThemeDisplayed in VF Pages gives the value of rendered theme / UITheme.getUITheme() in Javascript gives values of current rendered theme/ UserInfo.getUiThemeDisplayed() in Apex gives the value of rendered theme
Utility of knowing Theme:-
  1. For conditional rendering of fields in VF pages
  2. For conditional application of Stylesheets
  3. Detecting the current user experience context in JavaScript code is important if we are relying on JavaScript heavily, especially for purposes for managing navigation in our JavaScript code.
I will close it here as of now , but in case you think that the Assistant in Lightning needs to get more versatile please do upvote the following idea:-






Additionally if you feel that the "News Component" of Lightning in SFDC is not much help in its current form :-
  • not customisable w.r.t. websites from where the feed is pulled
  • not customisable w.r.t. context and keywords currently the algorithm matches exactly with the Account Name or is tightly coupled with the Account Name
You may want to upvote the following idea on "News Component" if the above issues too bothers you.

No comments:

Post a Comment