Show a toast message by using flow

Today we will learn about show a success message by using flow.

Step 1 :- Create a lightning component

ToastMessage.cmp

				
					<aura:component implements="lightning:availableForFlowActions">
    <aura:attribute name="type" type="string" default="success" />
    <aura:attribute name="messageText" type="string" />
</aura:component>
				
			

ToastMessageController.js

				
					({
    invoke : function(component, event, helper) {
        var message = component.get("v.messageText");
        var type = component.get("v.type");
        helper.showToast(component, event, helper, type, message);

    }
})
				
			

ToastMessageHelper.js

				
					({
    showToast : function(component, event, helper, type, message) {
        var toastEvent = $A.get("e.force:showToast");
        toastEvent.setParams({
            "message": message,
            "type": type,
            "duration": 10,
            "mode": "dismissible",
        });
        toastEvent.fire();
    }
})
				
			

ToastMessage.design

				
					<design:component >
    <design:attribute name="type" />
    <design:attribute name="messageText" />
</design:component>
				
			

Step 2 :- create a flow and drag a Action from Interaction section

Step 3 :- Select created component in Action

Step 4 :- Enter the message that you want to display into messageText box.

Output : -

Leave a Comment