+ Start a Discussion
diwakar rajputdiwakar rajput 

var navEvt = $A.get("e.force:navigateToSObject");this return undefined why? please help me to understand it

gotoRecord : function (component, event, helper) {
    var navEvt = $A.get("e.force:navigateToSObject");
        console.log("#####"+navEvt);
    navEvt.setParams({
      "recordId": "a0R7F000005ETrFUAW"
    });
    navEvt.fire();
}

 
Raj VakatiRaj Vakati

can you share the complete code? .. I didn't see any issue with the above code.

 It’s supported in Lightning Experience, Salesforce app, and Lightning communities.  If used outside, this event won’t be handled properly.

 
createRecord : function (component, event, helper) {
    var navEvt = $A.get("e.force:navigateToSObject");
    navEvt.setParams({
      "recordId": "00QB0000000ybNX",
      "slideDevName": "related"
    });
    navEvt.fire();
}


 
NagendraNagendra (Salesforce Developers) 
Hi Diwakar,

Sorry for this issue you are encountering.

May I request you please confirm if you are trying this on a desktop browser or Salesforce1?

If it is then the update from Salesforce is for LC4VF and for SF1 we still have to use sforce.one.navigatetosobject and force:navigateToSObject won't work.

Hope this will help you.

Kindly mark this as solved if the information is helpful.

Thanks,
Nagendra
Raj VakatiRaj Vakati

 Made a lightning app using Lightning app builder, and ran my component from salesforce1 . It ran successfully.
Dinesh vakati 9Dinesh vakati 9
try this
sforce.one.navigateToSObject("recordId","detail");