1

I have implemented this example provided here: https://salesforce.stackexchange.com/a/385665/138510 provided by @vitalii-dehnerys

But still, the Toast does not get fired from the LWC when it sits on a screen flow.

Does anyone else have this problem now too, OR do you have a work around?

3
  • Are you testing this in debug mode or in the actual Lightning Experience? Aug 24, 2023 at 17:27
  • Initially, yes, I was using the "Run" button in the flow designer. I also tried running the test flow from a URL ( /flow/my_flow ). In these cases, it did not work. But see below -- it DOES work when the flow is launched from an Action Button that specifically calls a named flow (not a URL button.)
    – Chubster
    Aug 24, 2023 at 19:48
  • note UnofficialSf.com show toast component in case you don't want to maintain your own lwc
    – cropredy
    Aug 25, 2023 at 0:04

2 Answers 2

4

The ShowToastEvent event does not work when the component is used in a Flow launched by a URL button.

If you really need a toast, you can make your own component: https://salesforcecodex.com/salesforce/custom-toast-with-custom-duration-in-lwc/

If you're using them for errors, there are some other options that aren't toasts: Show an error message in an LWC in a Flow using standard components

1
  • 5
    Actually, with more thorough testing, I can say that ShowToastEvent DOES work in a flow, as long as the flow is launched via an Action Button -- for example on a record page, as in the example. Where it does not work is when the flow is launched with a URL button, like what you might use on a listview (this is where I was using it.) So .... mixed results.
    – Chubster
    Aug 24, 2023 at 19:46
0

I asked in a comment before if you ran it with debug mode because of this: It works when it runs in a Lightning Experience UI. In debug mode and when run directly from the URL it doesn't work because it doesn't have the Lightning runtime available to handle the event and thus show the toast.

If you want to test your flow and see the toast, unfortunately you'll have to have an active version and run it on a Lightning Experience page.

1
  • Thanks @renato. In my case the flow is not launched in a traditional way -- it's launched by URL, which I think causes it to run inside of an Aura container. Something about how this flow is launched prevents the Toast from displaying. I've worked around it by popping alert boxes. I may go back and roll a toast-like component as others were suggested, but for now I'm good.
    – Chubster
    Sep 20, 2023 at 22:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .