• Pon Kumar
  • NEWBIE
  • 0 Points
  • Member since 2023

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies
Hi All,

I am trying to create a custom LWC component to register users in the community. I want to display the error messages to the users for any invalid data. I am trying to use toast messages to show the errors but can not see any message on the community.

I tried to put that component on a record page & I can see the toast message there but not sure why the message is not displayed on the community page.
Below is the sample code that I am trying to execute in the community:-
import { LightningElement } from 'lwc';
import saveUser from '@salesforce/apex/CommRegister.createUser';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';

export default class CommRegister extends LightningElement {
       
       registerUser()
	{
		saveUser()
		.then((result) => {
			console.log(result);
		})
		.catch((error) => {
			console.log(error);
			const evt = new ShowToastEvent({
                        title: 'Error',
                        message: 'This is an error message',
                        variant: 'error',
                        mode: 'dismissable'
                    });
                    this.dispatchEvent(evt);
		});
  	}
}
Is there any limitation of the community or any setting that needs to be enabled before using toasts in custom LWC?

Thanks.