• Abhishek Saxena 106
  • NEWBIE
  • 0 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 2
    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.
 
xx__c obj = [select xxnumber from xx__c];
in obj i will get the xxnumber's with comma seperated values (xxnumber = 12345,6789,09876). Here i need to split the comma's and add only the numbers to the list.