0

I have been searching for Toast Message on the VF page. Because I have called my LWC inside one Vf page. it is working fine but the Toast message is not accessible or we can say visible on the VF page.

So I have been searching about this but got nothing helpful. But thanks to the salesforce community I have found a way to call all Toast msg from Lwc to the Vf page in two line code snippet which will work on every vf page (This answer has been given by Bartosz Śliwiński ). Below is the Answer for this.

6
  • Hi and welcome to SFSE. Please read How to Ask and perhaps take the tour to understand how Q&As are handled on this site. You should frame the question and then provide a separate self-answer (in the "Your Answer" box, below) in this sort of situation. Better still, add an alternative answer to this existing Q&A. Nice to see you cite the original author of the solution.
    – Phil W
    Commented Dec 7, 2023 at 10:38
  • Does this answer your question? How can I show a LWC ToastEvent message in Visualforce?
    – Phil W
    Commented Dec 7, 2023 at 10:39
  • Does this answer your question? Toast mesage alert for visualforce page Commented Dec 7, 2023 at 11:31
  • Thank you so much @PhilW for the warm welcome & the guidance . Will keep this all in mind for future Q&A.
    – Sen Ashok
    Commented Dec 7, 2023 at 12:51
  • When I say "answer," I mean the one that you two (@PhilW & @Tushar Jadav) suggested. You know, I'm not sure if those answers resolved my issue or not, but they definitely are long and incomprehensible to me. hence the solution I've been provided (originally given by Bartosz Śliwiński) is more practical and simple to use.
    – Sen Ashok
    Commented Dec 7, 2023 at 12:56

1 Answer 1

0

use this code snippet inside the script tag,and above the $Lightning.use code that's it nothing else :

**document.addEventListener('lightning__showtoast', event => {
        sforce.one.showToast(event.toastAttributes);
    });**

More briefly if needed:

<script>
    document.addEventListener('lightning__showtoast', event => {
        sforce.one.showToast(event.toastAttributes);
    });
    $Lightning.use("c:YourOutApp", () => {
        ...
    });
</script>
4
  • 1
    It is good to include explanation as to what the solution is doing, not just the code. Including the citation of the original author would be good (like you had done). It also makes sense to include this answer as an answer in one or both of the existing questions, IMHO.
    – Phil W
    Commented Dec 7, 2023 at 13:06
  • For all those who need more brief about the Answer here's the original answer link: (salesforce.stackexchange.com/questions/267571/…). i am still in the learning phase so can't be the right person to say brief about the answer I have given.
    – Sen Ashok
    Commented Dec 7, 2023 at 13:30
  • Again thank you @PhilW for suggesting important things to me so that viewers can understand more clearly.
    – Sen Ashok
    Commented Dec 7, 2023 at 13:33
  • 1
    Ah! So the answer is already on this site. In which case this is definitely a duplicate (though I understand there was a lot of "old" information included that you needed to wade through).
    – Phil W
    Commented Dec 7, 2023 at 14:29

You must log in to answer this question.

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