Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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.
}
}
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)
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);
}
}
}
// 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 => {
.catch(error => {
console.log(JSON.stringify(error));
this.dispatchEvent(
new ShowToastEvent({
title: 'Error creating record',
message: error.body.message,
variant: 'error',
}),
);
});
}
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();
}
}
}
wiredTopAccounts({ error, data }) {
if (data) {
this.topAccounts = data.items;
} else if (error) {
this.dispatchEvent(
new ShowToastEvent({
message: String(error),
variant: "error",
})
);
}
}
notify(variant, title, message) {
this.dispatchEvent(new ShowToastEvent({ title, message, variant }));
}