Tuesday, 14 February 2017

Salesforce Lightning Show Toast Message


Below code is used to show toast message after success or failure actions. Toast can be shown as even warning messages.


                    var resultsToast = $A.get("e.force:showToast");
                    var SuccessMsg = $A.get("$Label.c.Approved_Success_Msg");
                 
                    resultsToast.setParams({
                     
                        "message": SuccessMsg,
                        "type": "success"
                     
                    });

                    resultsToast.fire();



Above code can be used in either controller.js or helper.js files. The color of the toast message will change based on the type parameter value passed to toast.

1 comment:

  1. Hi! i get the following error when I tried to use your code

    This page has an error. You might just need to refresh it.
    Error in $A.getCallback() [Cannot read property 'setParams' of undefined]

    Could you help me? thanks

    ReplyDelete