Fire Toast Message from Visualforce Page

Fire Toast Message from Visualforce Page

Witn Spring19, you can fire toast messages from Visualforce pages now.

Toast messages can be sent using “showToast” method which is the latest member in object. Which means, these messages can only be displayed in Salesforce Mobile app and would not be supported in desktop experience. The change applies to Lightning Experience, Lightning communities, and all versions of the mobile app.


Check out below example to display toast messages:

<apex:page >

    <script type=”text/javascript”>     

    window.onload = setupPage;

    function setupPage() {

        //function contains all code to execute after page is rendered

        //Showing a toast message{

            “title”: “Hello There!!”,

            “message”: “I am a toast message being fired from visualforce page”,

            “type”: “success” //supported types are error, success, info, warning





    <div> Toast Message Demo </div>



The supported types are, error, success, info and, warning. Once you add above VF page in Salesforce Mobile Navigation (Setup > Salesforce Navigation), you would see the visualforce tab in the menu. Opening the VF page in mobile app will display a toast like below:

Source: Salesforce Release Notes

Also Read: Share Data Between Lightning Component & Visualforce Page

Also Read: Apex/Visualforce New Features & Changes – #Winter19 Development Track Highlights

Manish Choudhari

I am a certified Salesforce Application & System Architect and Developer working on Salesforce Technology since 2014. Currently, I have 14 Salesforce certifications along with OCPJP (Oracle Certified Profession JavaSE6 Programmer) working in Hyderabad as a Technical Engineer. Writing technical blogs, learning new technologies and frameworks and sharing knowledge is my hobby.

This Post Has One Comment

  1. Hi Manish,

    Thanks for the post!It was really nice!!
    But i have to show this toast message in Desktop experience also. Is it possible in any way?


Leave a Reply

Close Menu