2

I'm testing lightning components and created a test app using out of the box events and none of them do anything. Here is my code for the client controller:

({
    goToRecord : function(component, event, helper) {
        let sObjectEvent = $A.get("e.force:navigateToSObject");
        sObjectEvent.setParams({
            "recordId": component.get("v.contact.Id"),
            "slideDevName": 'related'
        });
        sObjectEvent.fire();
    },
    editRecord : function(component, event, helper) {
        var editRecordEvent = $A.get("e.force:editRecord");
        editRecordEvent.setParams({
            "recordId": component.get("v.contact.Id")
        });
        editRecordEvent.fire();
        console.log('fired');
    },
    relatedList : function (component, event, helper) {
    var relatedListEvent = $A.get("e.force:navigateToRelatedList");
    relatedListEvent.setParams({
        "relatedListId": "Cases",
        "parentRecordId": component.get("v.recordId")
    });
    relatedListEvent.fire();
}
})

The console.log is showing so I know it is being called but it is not doing anything in the standalone lightning app.

3 Answers 3

3

Not all standard events are supported in standalone apps. A standalone Lightning App will not support any event that includes the following note in the documentation:

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

When you want to use an event, check the documentation to make sure it is supported as a standalone app event. Events that do not have this note will work in your standalone app with no extra effort; if they have this note, you must write your own handler if you want to support them in your standalone app.

2
  • Sfdcfox, what exactly do you mean by "you must write your own handler"? Are there any examples of such handlers?
    – hamayoun
    Feb 27, 2018 at 23:38
  • @hamayoun Follow the trail.
    – sfdcfox
    Feb 28, 2018 at 2:31
2

Some of the standard events like e.force:navigateToSObject,e.force:editRecord do not work without lightning app container .So in your test application they wont work .

If you take your lightning component and place it on the page using the lightning application builder or community builder you will see all these events working .

Use lightning app builder to test your component

0

This looks like a huge gap. Does this mean that such events are only available when accessed directly inside lightning app builder? And such events can't be used, for example, from visualforce pages?

You must log in to answer this question.

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