HTML
<template>
<lightning-button label="Delete Record" onclick={deleteRecord}></lightning-button>
</template>
Java Script
import { LightningElement, api, track } from 'lwc';
import { deleteRecord } from 'lightning/uiRecordApi';
import { NavigationMixin } from 'lightning/navigation';
export default class DeleteAccount extends NavigationMixin(LightningElement) {
@api recordId ='0038b00002in40SAAQ';
@api objectApiName;
deleteRecord() {
deleteRecord(this.recordId)
.then(() => {
// Record is deleted successfully
console.log('Record is deleted successfully');
// Navigate to account table
this[NavigationMixin.Navigate]({
type: 'standard__objectPage',
attributes: {
objectApiName: 'Account',
actionName: 'list'
},
});
})
.catch(error => {
// Handle error while deleting the record
console.error(error);
});
}
}
Video
Video does not exists.