$User.UIThemeDisplayed not working correctly from Custom Link
Last updated 2020-09-29 ·Reference W-6139378 ·Reported By 60 users
No Fix
Summary
$User.UIThemeDisplayed is always returning as Theme3 even when the user is on lightning interface
Repro
Steps to repro:
1) Create a new custom link on the Account
2) Enter {!$User.UIThemeDisplayed} in the URL space
3) Put the button on the Account flexipage
4) Go to an account page in Classic and click on the link.
5) Notice that the url of the page that loads says 'https://[instance].my.salesforce.com/servlet/Theme3'; which is expected, as you clicked the link from Classic
6) Switch to the lightning experience, go to the same account, and click the link
7) Notice that the url of the page that loads is 'https://[instance].my.salesforce.com/servlet/servlet.ExternalRedirect?url=Theme3';.
8) Whats Expected - It should say https://[instance].my.salesforce.com/servlet/servlet.ExternalRedirect?url=Theme4d'; instead, as you clicked the link from the Lightning Experience.
Workaround
For custom links, the {!$User.UITheme} and {!$User.UIThemeDisplayed} formula fields can be used in the URL, but they are evaluated after navigation begins. The formula fields are interpreted according to the destination URL, user settings, and the org default (in that order), regardless of whether the user clicked the custom link on a Lightning or Classic page.
If instead you need to construct a link where !$User.UIThemeDisplayed reflects the theme of the page where the link is clicked, rather than the link’s destination, create a different formula field. The new formula field should be of return type text and contian a HYPERLINK function.
For example, `HYPERLINK(“https://MyDomainName.my.salesforce.com/” + $User.UIThemeDisplayed, “link text”),` evaluates as a link to `https://MyDomainName.my.salesforce.com/theme3` when the field is viewed in Classic, and a link to `https://MyDomainName.my.salesforce.com/theme4d` when viewed in Lightning.
Reported By (60)






Is it Fixed?
Any unreleased services, features, statuses, or dates referenced in this or other public statements are not currently available and may not be delivered on time or at all. Customers who purchase our services should make their purchase decisions based upon features that are currently available.