Events Handled In Salesforce1 and Lightning Experience

Salesforce1 and Lightning Experience handle some events, which you can fire in your Lightning component.
If you fire one of these force or lightning events in your Lightning apps or components outside of Salesforce1 or Lightning Experience:
  • You must handle the event by using the <aura:handler> tag in the handling component.
  • Use the <aura:registerEvent> or <aura:dependency> tags to ensure that the event is sent to the client, when needed.
Event Name Description
force:closeQuickAction Closes a quick action panel. Only one quick action panel can be open in the app at a time.
force:createRecord Opens a page to create a record for the specified entityApiName, for example, “Account” or “myNamespace__MyObject__c”.
force:editRecord Opens the page to edit the record specified by recordId.
force:navigateToComponent (Beta) Navigates from one Lightning component to another.
force:navigateToList Navigates to the list view specified by listViewId.
force:navigateToObjectHome Navigates to the object home specified by the scope attribute.
force:navigateToRelatedList Navigates to the related list specified by parentRecordId.
force:navigateToSObject Navigates to an sObject record specified by recordId.
force:navigateToURL Navigates to the specified URL.
force:recordSave Saves a record.
force:recordSaveSuccess Indicates that the record has been successfully saved.
force:refreshView Reloads the view.
force:showToast Displays a toast notification with a message.
lightning:openFiles Opens one or more file records from the ContentDocument and ContentHubItem objects.

Customizing Client-Side Logic for Salesforce1, Lightning Experience, and Standalone Apps

Since Salesforce1 and Lightning Experience automatically handle many events, you have to do extra work if your component runs in a standalone app. Instantiating the event using $A.get() can help you determine if your component is running within Salesforce1 and Lightning Experience or a standalone app. For example, you want to display a toast when a component loads in Salesforce1 and Lightning Experience. You can fire the force:showToast event and set its parameters for Salesforce1 and Lightning Experience, but you have to create your own implementation for a standalone app.

displayToast : function (component, event, helper) {
    var toast = $A.get("e.force:showToast");
    if (toast){
        //fire the toast event in Salesforce1 and Lightning Experience
        toast.setParams({
            "title": "Success!",
            "message": "The component loaded successfully."
        });
        toast.fire();
    } else {
        //your toast implementation for a standalone app here
    }
}