I'm trying to create a link to redirect to Contact. Component

    <aura:attribute name="Contacts" type="Contact[]"/>
    <aura:iteration items="{!v.Contacts}" var="con">
<td><a onclick="{!c.navigateToRecord}" style="width:100%;">{!con.Name}</a></td>
<td> {!con.Email} </td>
<td> {!con.Contact_level__c} </td>
<td> {!con.Account.Name} </td>
<td> {!con.Owner.Name} </td>
<td> {!con.CreatedBy.Name} </td>
<td> {!con.CreatedDate} </td>


navigateToRecord : function(component, event, helper) {
     var navEvent = $A.get("e.force:navigateToSObject");
          recordId: component.get("v.contact").Id,
          slideDevName: "detail"

I get this Message

Cannot read property 'setParams' of undefined

Help me PLS, WHY?

1 Answer 1


This means that force:navigateToSObject is not supported in your current code. The documentation states:

This event is handled by the one.app container. It’s supported in Lightning Experience, the Salesforce app, and Lightning communities.

If you're using something else, like Lightning Out, you need to use a different syntax, such as window.location.

  • What am I suppose to do to deal with it? Aug 27, 2020 at 20:51
  • @AndreyBeloborodov It depends on the context. If the event is null, that means that you need to sforce.one (if available) or window.location.
    – sfdcfox
    Aug 27, 2020 at 20:54
  • I'm in lightning, I don't understand what does it mean =( Aug 27, 2020 at 21:18
  • @AndreyBeloborodov There's things like Lightning Out, etc. Without knowing more about the code is running, I don't have a specific answer. The point is, you only get this event if you're actually in Lightning.
    – sfdcfox
    Aug 28, 2020 at 1:24

You must log in to answer this question.

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