Thursday, May 27, 2021

Useful system application events for lightning developement

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!!

6 comments:

  1. Do you need Finance? Are you looking for Finance? Are you looking for finance to enlarge your business? We help individuals and companies to obtain finance for business expanding and to setup a new business ranging any amount. Get finance at affordable interest rate of 3%, Do you need this finance for business and to clear your bills? Then send us an email now for more information contact us now via (financialserviceoffer876@gmail.com) whats-App +918929509036 Dr James Eric Finance Pvt Ltd Thanks

    ReplyDelete
  2. Does your firm, company or industry need financial assistance?
    Do you need finance to start your business?
    Do you need personal loan?
    Loan for your home improvements
    Mortgage loan
    Debt consolidation loan
    Commercial loan
    Education loan
    Car loan
    Loan for assets.
    Contact us today with for your loan request:financialserviceoffer876@gmail.com
    Mobile phone number:+918929509036

    ReplyDelete
  3. I am so delighted I found your weblog, I really found you by accident,
    while I was researching on Bing for something else, Regardless I am here now and would just like to say thank you for a fantastic post and a all round entertaining blog (I also love the theme/design), HOW TO GET A FAKE DRIVERS LICENSE THAT WORKS FROM THE DMV I don't have time to go through it all at the minute but I have bookmarked it and also added your RSS feeds, so when I have time I will be back to read a lot more, Please do keep up the excellent job.

    ReplyDelete