Monday, January 21, 2019

Show Toast messages in Visualforce pages

This post explains how to fire toast messages from visualforce page.
In spring 19 release salesforce introduces the{toastParams}) function in object.
by using the function you can show different severity like success, error, info, warning.
Note: The change applies to Lightning Experience, Lightning communities, and all versions of the mobile app.
VF page
<apex:page lightningStylesheets="true">
        function showToast() {
                "title": "Success!",
                "message": "Welcome to salesforce code crack.",
                "type": "success"
    <apex:form >
        <apex:page >
            <apex:commandButton value="Show Toast" onclick="showToast();" />
Enable the Available for Lightning Experience, Lightning Communities, and the mobile app permission.
Check below screenshot
once you enable the checkbox, add the visualforce page in salesforce mobile navigation

Happy Learning!!!