I have a lightning component hosted in Visualforce page. Lightning Experience is not enabled and it is still Salesforce Classic. I have records displayed in data table. When record name is clicked I want to navigate to record detail page.

Below is my code


<aura:component >
    <aura:attribute name="CurrentItem" type="Company__c" /> 


       <td data-label="Name">
           <div class="slds-truncate" title="{!v.CurrentItem.Name}"><a href="" onclick = "{!c.navigateToRecordPage}">{!v.CurrentItem.Name}</a></div>

       <td data-label="City">
           <div class="slds-truncate" title="{!v.CurrentItem.City__c}">{!v.CurrentItem.City__c}</div>
       <td data-label="State">
           <div class="slds-truncate" title="{!v.CurrentItem.State__c}">{!v.CurrentItem.State__c}</div>



    navigateToRecordPage: function(component, event, helper) {

        //var parentrec = component.get("v.CurrentItem");

        //but it throws error when component is in VF page and lightning experience // is not enabled, it is still salesforce classic                

        var navEvt = $A.get("e.force:navigateToSObject");
        var parentrec = component.get("v.CurrentItem");
        "recordId": parentrec.Id        



Below are various options I used to do navigation to record detail page but I am receiving error for all of them.


Using force:navigateToSObject - ERROR - Action Failed [Cannot read property 'setParams' of undefined] Failing descriptor:


Using sforce.one.navigateToSObject - ERROR Action Failed [sforce is not defined] Failing descriptor


hardcoding link in href attribute like "/objectid" EXCEPTION - receiving SAME ORIGIN EXception

I have similar code using force:navigateToSObject working correctly in another org which has Lightning Experience enabled. I assume these issues could be related to Salesforce Classic and related to the containers.

Any idea how I can get around this without switching on Lightning Experience ?

2 Answers 2


You can try using plain old JavaScript for classic like

window.location.assign=url here

may want to detect whether you are inside Lightning container or classic and based on that for classic use simple window navigation

  • Mohith, Could you please clarify ? Is this not going to be SAME ORIGIN issue ?
    – apn
    Dec 24, 2016 at 2:46
  • It's not going to give you same origin as you are redirecting browser window to new url .Have you tried it ? Dec 24, 2016 at 2:48
  • I changed the code as below but still seeing the same origin error ({ navigateToRecordPage : function(component, event, helper) { var parentrec = component.get("v.CurrentItem"); window.location.href= "/" + parentrec.Id; } })
    – apn
    Dec 24, 2016 at 2:52
  • Are you using Lightning out on vf? Dec 24, 2016 at 2:57
  • Yes, I have Outer component in VF page. Outer component uses another inner component. Code snippet given in the question is inner component's code. Click event is for inner component
    – apn
    Dec 24, 2016 at 3:00

So below is the resolution to this issue, I was receiving below error, Refused to display 'https://xxxx.my.salesforce.com/xxxxxx' in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN' I had "Development Mode" switched on. After switching it off, I was able to navigate without any errors.

Hope this helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.