You need to sign in to do that
Don't have an account?
Unable to print Error toast message
Hope you're doing well.
I want to print an error toast, the pop-up appearing but the message is not printing.
I researched and tried a lot about that but was unsuccessful.
Below is my JS controller.
Any help would be appreciated.
Thanks and Regards,
Prince Sharma.
I want to print an error toast, the pop-up appearing but the message is not printing.
I researched and tried a lot about that but was unsuccessful.
Below is my JS controller.
import { ShowToastEvent } from 'lightning/platformShowToastEvent'; handleTimesheet() { saveData({ firstName :this.firstName, lastName :this.lastName, accountId :this.recordId }) .then(result => { //Shows Success Toast Event const e = new ShowToastEvent({ title: 'Success', message: result, variant: 'success', mode: 'dismissable', }); this.dispatchEvent(e); // console.log('result: ' +result); }) .catch(error => { //Shows Error Toast Event const e = new ShowToastEvent({ title: 'Error Occured', message: error.body.message, // I TRIED THIS AND THE BELOW LINE AS WELL message: error.body.output.errors[0].message, // I GOT ERROR ON THIS LINE "Cannot read properties of undefined (reading 'errors')" variant: 'error', mode: 'dismissable', }); this.dispatchEvent(e); console.log('Error: ', JSON.stringify(error)); }) }
Any help would be appreciated.
Thanks and Regards,
Prince Sharma.
Please refer the below article will help you to proceed further.
https://developer.salesforce.com/docs/component-library/documentation/en/lwc/use_toast
https://www.sfdcpoint.com/salesforce/lightning-web-component-lwc-toast-messages/
Thanks!!
I've checked both the link yestarday.
Thanks!