lightning Toast message is not showing when i click on save button. Is that anything wrong in the below code. Please help me on this.
<div class="slds-size_2-of-2">
<lightning-button type="submit" variant="brand" value="AddParent" name="AddParent" label="Save" onclick={handleonClickParent}>
</lightning-button>
</div>
JS:
handleonClickParent() {
createParentGuardian({
firstName: this.firstname,
lastName: this.lastName,
phone: this.phone,
email: this.email,
studentRelation: this.relationship
})
.then(result => {
const evt = new ShowToastEvent({
title: "success",
message: "Sucessfully Created",
variant: "Success"
})
this.dispatchEvent(evt);
})
}
@AuraEnabled
public static void createParentGuardian(string firstName, string lastName, string phone, string email, string studentRelation) {
system.debug('firstName ' + firstName);
system.debug('lastName ' + lastName);
system.debug('phone ' + phone);
system.debug('email ' + email);
system.debug('studentRelation ' + studentRelation);
try {
Contact newContact = new Contact (
FirstName = firstName,
//LastName = lastName,
Email = email,
Phone = phone,
Student_Relation__c = studentRelation,
RecordTypeId = '0122w000000HM1pAAG'
);
//insert newContact;
} catch (Exception e) {
}
}
handleonClickParent
shouldn't have parameters, 2)variant
should be a lowercasesuccess
3) Thealert(evt)
might also have prevented the message even if you weren't in a Visualforce environment.