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
shiv kumar 48shiv kumar 48 

How to redirect to record view from classic , lightning and sf1 from Visualforce page

How to redirect to record view from classic , lightning and sf1 from Visualforce page ?
Shruti SShruti S
You can use Navigation with sforce.one Object to achieve this. If you want to know if you are in a Classic theme or Lightning theme, you can use $User.UITheme . If its value is 'Theme4t' or 'Theme4d' then it means it is in Lightning or SF1. If its value is 'Theme3', it means its in Classic theme.
Here is the code for this to work (I have just used a sample Account record for the sake of demo) - 
<apex:page>
    <apex:outputPanel rendered="{!$User.UITheme == 'Theme3'}">
        <button onclick="gotoClassicView()">Go to Burlington</button>
    </apex:outputPanel>
    <apex:outputPanel rendered="{!$User.UITheme == 'Theme4t' || $User.UITheme == 'Theme4d' }">
        <button onclick="gotoLightningView()">Go to Dickenson</button>
    </apex:outputPanel>
    <script type="text/javascript">
        var gotoClassicView = function() {
            location.href = "/0012800000NqwPy";
        };
        
        var gotoLightningView = function() {
            sforce.one.navigateToSObject( "0012800000NqwQ0" );
        };
    </script>
</apex:page>

Reference :
  1. Theme Detection - https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_variables_global_useruitheme.htm
  2. Navigation in Lightning Experience and SF1 - https://developer.salesforce.com/docs/atlas.en-us.salesforce1.meta/salesforce1/salesforce1_dev_jsapi_sforce_one.htm