How to use the lightning/platformShowToastEvent.ShowToastEvent function in lightning

To help you get started, we’ve selected a few lightning examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tsalb / lwc-utils / force-app / main / default / lwc / lwcContactAddressForm / lwcContactAddressForm.js View on Github external
handleSuccess() {
    this.dispatchEvent(new ShowToastEvent({
      title: null,
      message: 'Updated Mailing Address Successfully.',
      variant: 'success'
    }));
    fireEvent(this.pageRef, 'forceRefreshView'); // actually targets the datatable for the refresh.
    this.template.querySelector('c-message-broker').notifyClose(); // consistent to use the @api in case implementation changes. do not fire event directly.
  }
}
github barryhughes1 / pluralSightQuestionnaires_LWCs / 04. Completed Solution / main / questionnaires / lwc / questionnaireLwc / questionnaireLwc.js View on Github external
markQuestionnaireComplete() {
        if(!this.termsConditions) {

            this.dispatchEvent(
                new ShowToastEvent({
                    title: 'Warning',
                    message: 'You must agree to terms and conditions before submitting',
                    variant: 'warning',
                }),
            );

        } else {
            // Multiple pages - referential integrity #2 (@kevinv11n)
            const fields = {};
            fields[ID_FIELD.fieldApiName] = this.questionnaireReturnedId;
            fields[QUESTIONNAIRE_FIELD.fieldApiName] = this.selectedQuestionnaireId;
            fields[TANDC_FIELD.fieldApiName] = this.termsConditions;
            fields[SUBMITTED_FIELD.fieldApiName] = true;
            fields[ANSWERED_BY_FIELD.fieldApiName] = this.answeredBy;
            let record = {fields};            
            updateRecord(record)
github pozil / sfdc-ui-lookup-lwc / src-sample / main / default / lwc / sampleLookupContainer / sampleLookupContainer.js View on Github external
notifyUser(title, message, variant) {
        if (this.notifyViaAlerts) {
            // Notify via alert
            // eslint-disable-next-line no-alert
            alert(`${title}\n${message}`);
        } else {
            // Notify via toast
            const toastEvent = new ShowToastEvent({ title, message, variant });
            this.dispatchEvent(toastEvent);
        }
    }
}
github barryhughes1 / pluralSightQuestionnaires_LWCs / 04. Completed Solution / main / questionnaires / lwc / questionnaireLwc / questionnaireLwc.js View on Github external
// sending an update event to the parent questionnaireList component
               const updateEvent = new CustomEvent('updatequestionnairelist', { 
                detail: {
                    operation: 'New Return',
                    newQuestionnaireReturnID: this.questionnaireReturnedId,
                   },
                 bubbles: true                   
               });        
               // Dispatches the event.
               this.dispatchEvent(updateEvent);    
              

               // Toast
                this.dispatchEvent(
                    new ShowToastEvent({
                        title: 'Success',
                        message: 'Questionnaire saved',
                        variant: 'success',
                    }),
                );
            })
            .catch(error => {
github barryhughes1 / pluralSightQuestionnaires_LWCs / force-app / main / questionnaires / lwc / questionnaireAnswer / questionnaireAnswer.js View on Github external
.catch(error => {
               console.log(JSON.stringify(error));
                this.dispatchEvent(
                    new ShowToastEvent({
                        title: 'Error creating record',
                        message: error.body.message,
                        variant: 'error',
                    }),
                );
            });
    }
github tsalb / lwc-utils / force-app / main / default / lwc / lwcContactDatatable / lwcContactDatatable.js View on Github external
async reloadTable() {
    try {
      this.contacts.data = await getContactsByAccountId({accountId: this._accountId});
    } catch (error) {
      this.dispatchEvent(
        new ShowToastEvent({
          message: String(error),
          variant: 'error',
        })
      );
    } finally {
      this.template.querySelector('c-event-broker').forceRefreshView();
    }
  }
}
github tsalb / lwc-utils / force-app / main / default / lwc / lwcAccountSelector / lwcAccountSelector.js View on Github external
wiredTopAccounts({ error, data }) {
    if (data) {
      this.topAccounts = data.items;
    } else if (error) {
      this.dispatchEvent(
        new ShowToastEvent({
          message: String(error),
          variant: "error",
        })
      );
    }
  }
github pozil / streaming-monitor / src / main / default / lwc / streamingMonitor / streamingMonitor.js View on Github external
notify(variant, title, message) {
        this.dispatchEvent(new ShowToastEvent({ title, message, variant }));
    }