3

I created an apex:outputlink that works fine in regular VF but when I add the lightning experience wrapper it doesn't work.

my code is here:

 <apex:outputLink  value="/one/one.app#/sObject/{!Account.id}/view">
        {!Account.name}
 </apex:outputLink>

the error is:

This page isn't available in Salesforce Lightning Experience or Salesforce1.

0

1 Answer 1

4

You need to use force: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.

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.

  • 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');
}
5
  • hi ratan! thank you! can this be done on the visual force page? i'm trying to have this appear in lightning experience and it says it's available for salesforce1 only
    – soxdave
    Commented Feb 20, 2016 at 4:18
  • @soxdave For vf page you need to use something else... one minute
    – Ratan Paul
    Commented Feb 20, 2016 at 4:20
  • @soxdave check my updates ans
    – Ratan Paul
    Commented Feb 20, 2016 at 4:25
  • thanks. so do i need to have two different coding implementations for salesforce1 and for desktop? how do i detect for that??? not so easy.
    – soxdave
    Commented Feb 20, 2016 at 4:28
  • @soxdave Yes.. You need to implement two different coding
    – Ratan Paul
    Commented Feb 20, 2016 at 4:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .