You need to use force:navigateToSObjectforce:navigateToSObject
(documentation) for lightning
Navigates to an sObject record specified by recordId.
To display the record view, set the record ID on the recordId attribute and fire the event. The record view contains slides that displays the Chatter feed, the record details, and related information. This example displays the related information slide of a record view for the specified record ID.
Navigates to an sObject record specified by recordId.
To display the record view, set the record ID on the recordId attribute and fire the event. The record view contains slides that displays the Chatter feed, the record details, and related information. This example displays the related information slide of a record view for the specified record ID.
createRecord : function (component, event, helper) {
var navEvt = $A.get("e.force:navigateToSObject");
navEvt.setParams({
"recordId": "00QB0000000ybNX",
"slideDevName": "related"
});
navEvt.fire();
}
For visualforce
Navigation with the sforce.one Object
sforce.one.navigateToSObject
Navigates to an sObject record, specified by recordId. This record “home” has several views, which in Salesforce1 are available as slides that the user can swipe between.
view is optional and defaults to detail. view specifies the slide within record home to display initially. The possible values are as follows.sforce.one.navigateToSObject
- detail: the record detail slide
- chatter: the Chatter slide
- related: the view of related slide
Navigates to an sObject record, specified by recordId. This record “home” has several views, which in Salesforce1 are available as slides that the user can swipe between. view is optional and defaults to detail. view specifies the slide within record home to display initially. The possible values are as follows.
- detail: the record detail slide
- chatter: the Chatter slide
- related: the view of related slide
Example
<apex:outputLink onclick="navSObject('{!Account.Id}')">
{!Account.name}
</apex:outputLink>
<script>
function navSObject(reciord)
{
sforce.one.navigateToSObject(reciord,"detail");
};
</script>
Detect you are in mobile or desktop use below code
if(typeof sforce !== "undefined" && sforce !== null) {
// Salesforce1 navigation
sforce.one.navigateToSObject(accountId);
} else {
// Desktop navigation
window.open('/'+accountId, '_self');
}