Newer Version Available
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 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: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: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. |
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.
1displayToast : function (component, event, helper) {
2 var toast = $A.get("e.force:showToast");
3 if (toast){
4 //fire the toast event in Salesforce1 and Lightning Experience
5 toast.setParams({
6 "title": "Success!",
7 "message": "The component loaded successfully."
8 });
9 toast.fire();
10 } else {
11 //your toast implementation for a standalone app here
12 }
13}