Create lightning platform show toast event/dispatchEvent where display toast message with hyperlink click button and navigate to external link in Salesforce lightning web component LWC | how to display toast message with hyperlink and navigate to external URL uses of ShowToastEvent / NavigationMixin in Salesforce LWC

Vijayk
4 min readNov 28, 2021

--

Hey guys, today in this post we are going to learn about how to Create lightning platform show toast event/dispatchEvent where display toast message with hyperlink click button and navigate to external link in Salesforce lightning web component LWC

To trigger a toast from a Lightning web component, in the component’s JavaScript class, import ShowToastEvent from lightning/platformShowToastEvent. Create a ShowToastEvent with a few parameters, and dispatch it. The app handles the rest.

In this example, when a user clicks the button, the app displays a toast with the info variant, which is the default. The toast remains visible for 3 seconds or until the user clicks the close button, denoted by the X in the top right corner, which is also the default. To know more details about Platform Show Toast Event, Click Here.

Parameters of display a toast message →

title

String

(Required) The title of the toast, displayed as a heading.

message

String

(Required) A string representing the body of the message. It can contain placeholders in the form of {0} … {N}. The placeholders are replaced with the links on messageData.

messageData

String[] or Object

url and label values that replace the {index} placeholders in the message string.

variant

String

Changes the appearance of the notice. Toasts inherit styling from toasts in the Lightning Design System. Valid values are: info (default), success, warning, and error.

mode

String

Determines how persistent the toast is. Valid values are: dismissible (default), remains visible until you click the close button or 3 seconds has elapsed, whichever comes first; pester, remains visible for 3 seconds and disappears automatically. No close button is provided; sticky, remains visible until you click the close button.

Files we used to display hyperlink toast in Salesforce LWC →

lwcToastEvent.html

LWc HTML File

Template HTML file to display hyperlink toast in Salesforce Lightning Web Component (LWC)

lwcToastEvent.js

LWC JavaScript File

It’s hold handleClick action method to display toast messages with link in Salesforce LWC.

lwcToastEvent.js-meta.xml

XML Meta File

It is used to where this lightning web component file you want to display as lightning__AppPage, lightning__RecordPage, lightning__HomePage.

Final Output → To know more details, get source code live demo link, Click Here..

Other related post that would you like to learn in LWC

Create Lightning Web Component HTML →

Step 1:- Create Lightning Web Component : lwcToastEvent.html

SFDX:Lightning Web Component >> New >> lwcToastEvent.html

lwcToastEvent.html [Lightning Web Component HTML]

Create Lightning Web Component JavaScript →

Step 2:- Create Lightning Web Component : lwcToastEvent.js

SFDX:Lightning Web Component >> New >> lwcToastEvent.js

lwcToastEvent.js [LWC JavaScript File]

Create Lightning Web Component Meta XML →

Step 3:- Create Lightning Web Component : lwcToastEvent.js-meta.xml

SFDX:Lightning Web Component >> New >> lwcToastEvent.js-meta.xml

lwcToastEvent.js-meta.xml [LWC Meta Data XML]

Lightning Web Component Meta XML

Further post that would you like to learn in LWC Flyout is a free, simple way to earn money.

If you think you and your family members also like to earn money in additional time, then go this link. In this site, you can earn money for the lifetime at low effort. To Earn Unlimited Everyday With This Trick, Sign Up Free.. Get Started for Free

Flyout is a free, simple way to earn money by placing sponsored content on your blog

Check Out:- Earn Unlimited Everyday With This Trick:- Click Here

FAQ (Frequently Asked Questions)

Final Output → To know more details, get source code live demo link, Click Here..

Hi, This is Vijay behind the admin and founder of w3web.net. I am a senior software developer and working in MNC company from more than 8 years. I am great fan of technology, configuration, customization & development. Apart of this, I love to write about Blogging in spare time, Working on Mobile & Web application development, Salesforce lightning, Salesforce LWC and Salesforce Integration development in full time. [Read full bio] | The Sitemap where you can find all published post on w3web.net

Originally published at https://www.w3web.net on November 28, 2021.

--

--

Vijayk
Vijayk

Written by Vijayk

Easy to learn step-by-step online tutorial by www.w3web.net

No responses yet