Newer Version Available
Salesforce1 Events
You can fire the following events, which are automatically handled by Salesforce1. If you fire these events in your Lightning apps or components outside of Salesforce1, you must handle them as necessary.
| Event Name | Description |
|---|---|
| force:createRecord | Opens the page to create a new 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 message in a popup. |
Customizing Client-Side Logic for Salesforce1 and a Standalone App
Since Salesforce1 automatically handles many events, you have to do extra work if your component runs in a standalone app. Instantiating a Salesforce1 event using $A.get() can help you determine if your component is running within Salesforce1 or a standalone app. For example, you want to display a toast when a component loads in Salesforce1 and in a standalone app. You can fire the force:showToast event and set its parameters for Salesforce1 and 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
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}