3

This Salesforce Documentation suggests that we can detect which User Interface is being displayed by using the $User.UITheme and $User.UIThemeDisplayed global variables and the UserInfo.getUiTheme() and the UserInfo.getUiThemeDisplayed() Apex methods. In my org, I have enabled the Lightning experience for my user and switched over to the new UI. However, when I try to detect the interface using either in Visualforce using the global variables on through the Developer Console using the Apex methods, it keeps returning 'Theme3' and not 'Theme4d' as is expected. Has anyone else run into this issue? Are there more steps to Enable Lightning that I'm missing?

  • I know getUiTheme() return the "preferred" theme. But getUiThemeDisplayed must display the current one? Otherwise you could check if sforce.one is available in Javascript. – Cloud Ninja Aug 31 '16 at 22:43
  • This was user error. I had Lightning Enabled, but I was checking the $User.UITheme and $User.UIThemeDisplayed whiled in Classic Mode. – Suryatej Mukkamalla Sep 1 '16 at 2:11
  • @SuryatejMukkamalla Do you want to answer your own question with a description of what the problem was? – Daniel Ballinger Sep 6 '16 at 21:15
2

This was just user error on my part. Although I had Lightning enabled, I had not switched to it when I was trying to detect the UI Theme. Once I switched to the Lightning view, it was detecting the UI Theme correctly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.