Below is list of application events which is very useful and can be used frequently in lightning development.
Note: These events are supported in Lightning Experience, the Salesforce mobile app, and Aura-based Experience Builder sites.
- force:closeQuickAction
To close a quick action panel, you can use force:closeQuickAction event
var navEvent = $A.get("e.force:closeQuickAction");
if(navEvent){
navEvent.fire();
}
- force:navigateToList
This event helps you to navigate to list view based on ListviewId specified.
var navEvent = $A.get("e.force:navigateToList");
if(navEvent){
navEvent.setParams({
"listViewId": listviews.Id,
"listViewName": null,
"scope": "Account"
});
navEvent.fire();
}
How to get list view id using SOQL
SELECT Id FROM ListView WHERE SobjectType = 'Account' and Name='All Accounts' Limit 1
- force:navigateToURL
This event helps you to navigate to URL specified in parameter.
var navEvent= $A.get("e.force:navigateToURL");
if(navEvent){
navEvent.setParams({
"url": "/001/"
});
navEvent.fire();
}
- force:refreshView
To refresh or reload standard or custom component, use this event. This event ideally reload data without page refresh.
var navEvent= $A.get("e.force:refreshView");
if(navEvent){
navEvent.fire();
}
Note: This event impact performance and should be avoided. Also avoid repeated firing of this event from same component
- force:showToast
This event can be used to display message below the header at the top of a view. You can specify the message and type (warning, success, info, other) and based on that color of message panel will changes. Default is other which shows panel similar to info.
showToastMessage:function(title,msg,duration,key,type,mode){
var toastEvent = $A.get("e.force:showToast");
if(toastEvent){
toastEvent.setParams({
"title": title,
"message": msg,
"duration":duration,
"type": type,
"mode": mode
});
toastEvent.fire();
}
}
Default value for mode is "dismissible" which display close icon. In duration you can specify the time in millisecond. Toast will remain in screen for this duration.
- force:force:navigateToSObject
This event help you to navigate to record details page based on recordId specified:
var navEvent= $A.get("e.force:navigateToSObject");
if(navEvent){
navEvent.setParams({
"recordId": "003B0000000ybYX"
});
navEvent.fire();
}
Hope this help!!