0

I am working on migrating LWC into visualforce app.
Almost all functionalities working fine, but ShowToastEvent and dispatchEvent method are not working in Visualforce environmnent.

I walked throught instructions below. But it's not working.
https://developer.salesforce.com/docs/component-library/documentation/lwc/use_visualforce

How should I do for this?

ex. My code looks like below.

class SomeClass extends LightningElement {

  showToastOperation(operation) {
    let msgStr = '';
    switch (operation) {
      case Operation.GET:
        msgStr = message_operation_get;
        break;
      case Operation.CREATE:
        msgStr = message_operation_create;
...
      default:
        throw new Error('Unknown operation!');
    }
    this.dispatchEvent(
      new ShowToastEvent({
        title: 'Success!!',
        message: msgStr,
        variant: 'success',
      })
    );
  }

1 Answer 1

1

The ShowToastEvent() of LWC is not intended for Visualforce environments. The current support for this event is "Lightning Experience" only.

https://developer.salesforce.com/docs/component-library/bundle/lightning-platform-show-toast-event/documentation

Here is a documentation for ltng:outApp considerations with standard events.

https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/lightning_out_considerations.htm

That being said - even the Aura Component version of "Show Toast Event" was supported only in one.app environments ie (Lightning Experience , Salesforce Mobile App & Lightning Communities).

Reference :

https://developer.salesforce.com/docs/atlas.en-us.212.0.lightning.meta/lightning/ref_force_showToast.htm?search_text=force:showToast

You must log in to answer this question.

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