I am trying to use the "navigateToSObject" to redirect to the detail page. But the method $A.get("e.force:navigateToSObject") is always returning null. I dont have a namespace. SO this isn't namespace related issue I assume.
Here is the code of my component
<aura:component >
<aura:attribute name="contactName" type="String"></aura:attribute>
<aura:attribute name="lastName" type="String"></aura:attribute>
<aura:attribute name="cid" type="String"></aura:attribute>
<div onclick="{!c.navigateToRecord}" >
<h1>{!v.lastName}</h1>
<h3>{!v.contactName}</h3>
<h3>{!v.cid}</h3>
</div>
</aura:component>
Here is the code of my java-script controller
({
navigateToRecord : function(component, event, helper){
var cid=component.get("v.cid")
console.log('inside navigateToRecord '+cid);
var navEvent = $A.get("e.force:navigateToSObject");
navEvent.setParams({
"recordId": cid,
"slideDevName": "detail"
});
navEvent.fire();
}
})
I am getting null in navEvent hence am not able to set parameters into it. The error is "Uncaught error in $A.run() : Cannot read property 'setParams' of null"