Activity Forums Salesforce® Discussions how to show toast message box in a lightning component ?

  • how to show toast message box in a lightning component ?

    Posted by Yogesh on October 17, 2019 at 7:23 am

    I want to show a error message on a condition in a lightning component.

    Saddam replied 5 years ago 3 Members · 2 Replies
  • 2 Replies
  • K

    Member
    October 20, 2019 at 5:27 am

    Hi Yogesh,

    You can use "showToast" out-of-box event.

     

    var showToastMsg=$A.get("e.force.showToast");

    showToastMsg.setParams({

    message : "Your error message" ,

    type : "error"

    });

    showToastMsg.fire();

     

     

    if you want you can pass dynamic params to message.

     

    Thanks

    Srinivas

     

     

  • Saddam

    Member
    October 21, 2019 at 9:58 am

    Hi,

    A toast displays a message below the header at the top of a view. The message is specified by the message attribute.

    force:showToast is not available on login pages.

    This example displays a toast message "Success! The record has been updated successfully.

    showToast : function(component, event, helper) {
    var toastEvent = $A.get("e.force:showToast");
    toastEvent.setParams({
    "title": "Success!",
    "message": "The record has been updated successfully."
    });
    toastEvent.fire();
    }

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos