Select your Language

Tost Error message show on lightning component

 Add this code in any Lightning component controller

1. With Event

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

                toastEvent.setParams({

                    title : 'Error',

                    message: 'Something went wrong. Please contact System Administrator!',

                    duration:' 5000',

                    key: 'info_alt',

                    type: 'error',

                    mode: 'sticky'

                });

              toastEvent.fire();


=========================================================

2. Without fire any event

Use markeup in Component :    

 <lightning:notificationsLibrary aura:id="notifLib"/>

Use javascript in Controller:

 component.find('notifLib').showToast({

                        "title": "Error!",

                        "message": "Please remove the Row, duplicates participates has been found",

                        "variant" : "error",

                        "mode": "sticky"

                    });

Reference: https://www.biswajeetsamal.com/blog/display-toast-message-in-lighting-component/

No comments:

Post a Comment