function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
DaAyDaAy 

$User.UITheme and $User.UIThemeDisplayed not working on setup section of Lightning pages

Hi,

In the setup section of a lightning enviornment $User.UITheme and $User.UIThemeDisplayed displays Theme3 whereas it should display Theme4d. Is this a bug? Is there a workaround for detecting the environment whether classic or lightning on setup pages? I have a visualforce page embedded in the user detail page and want to detect the environment from it. 

Thanks  
David HalesDavid Hales
Hi, the below workaround code worked for me to differentiate between Classic & Lightning UI.
<apex:page showHeader="true" sidebar="true">
  <apex:outputPanel rendered="{!$User.UITheme == 'Theme3'}">Currently in Classic UI</apex:outputPanel><br/> 
   <apex:outputPanel rendered="{!$User.UITheme != 'Theme3'}">Currently in Lightning Experience UI</apex:outputPanel>
</apex:page>


If the above suggestion worked, let us know by marking the answer as "Best Answer" right under the comment which will help the rest of the community should they have a similar issue in the future. 

Thanks & Regards 
David Hales(1044)
DaAyDaAy
Hi David,

Thanks for your response. The solution you have given works on the normal pages but on the user detail page which is accessed as part of the setup page it does not work .
David HalesDavid Hales
Hi DaAy, 
can you show me your code and screenshot which page you got error,

Thanks & Regards 
David Hales(1044) 

 
DaAyDaAy
Hi, Below is the screenshot  Following is the code for 'Invite User' button along with the the javascript that is called Javascript :function goToEventDetailPage(eventId){    return navigateTo('Some URL');} function navigateTo(urlToNavigate){    alert('This is $User.UIThemeDisplayed '+'{! $User.UIThemeDisplayed }');    alert('This is $User.UITheme '+'{! $User.UITheme }');} Thanks
DaAyDaAy
You can view the screenshot here https://drive.google.com/open?id=0B9aeVy2OdQb9R2dNRFktOUZVNXM
David HalesDavid Hales
Hi DaAy,
go through with 
https://salesforce.stackexchange.com/questions/167703/whats-the-expected-behavior-of-userinfo-getuithemedisplayed/167704

https://salesforce.stackexchange.com/questions/111518/firefox-browser-user-uitheme-and-user-uithemedisplayed-return-wrong-value-in


If the above suggestion worked, let us know by marking the answer as "Best Answer" right under the comment which will help the rest of the community should they have a similar issue in the future. 

Thanks & Regards 
David Hales(1044)
Kloudrac Softwares Pvt. Ltd.

 
DaAyDaAy
Hi David,
That has not solved the problem. I am still getting value of 'theme3' returned from variables $User.UITheme and $User.UIThemeDisplayed when I access a visualforce page embedded in hte user detail page accessed from Lightning Experience. This only happens in the user detail page, if I were to embed the same code into the Lead detail page or Contact detail page through a visualforce page the value correctly displays value 'Theme4d' in the lightning experience and value 'Theme3' in the classic environment. I am pretty sure this sound like a bug 

Thanks
DaAyDaAy
Anybody??? Help would be appreciated 
Thanks
Terry HamerTerry Hamer
I have experienced the same with an embedded visualforce page on the Account detail page. The weird thing is that it works on all orgs I have access to and have tested, except for one  that resides on the cs83 instance.

What instance are you accessing?
What browser are you using?
DaAyDaAy
Hi, Thanks for the reply I contact SF support and they said that this is an issue on the Salesforce (bug). It will get fixed sometime next year
davelelanddaveleland
@DaAy - just checking to see if you've heard any more about this?
DaAyDaAy
Hi, Salesforce confirmed it was a bug and they are working on the fix. May take EOY for the fix to be in place Thanks