Show a Toast with a New JavaScript Function

Show a toast with the sforce.one.showToast() function. A toast displays a message below the header at the top of a view.

Where: This change applies to Lightning Experience, Lightning communities, and all versions of the mobile app. The function is available for Visualforce pages set to API version 45.0.

How: The syntax of the function is:

sforce.one.showToast({toastParams})

The toastParams object sets the attributes for the toast, such as the toast title and message. Use any attribute available for the force:showToast Aura event.

The sforce.one.showToast function is a wrapper for the force:showToast Aura event. For details of all available attributes, see force:showToast in the Component Library.

Example

Show a toast on a Visualforce page using sforce.one.showToast.
sforce.one.showToast({
    "title": "Success!",
    "message": "The record was updated successfully."
});