Code: deleteAccount.html


<template>
    <!--  vh. Delete Button to add to an Account Record Page -->
    <hr>  
    <lightning-card title="LWC - Delete Record" icon-name="standard:record">
        Record Id to Delete : - {recordId} ->&nbsp;
        <lightning-button name="delete" label="delete" onclick={deleteAccount} 
            data-recordid={recordId}>        
        </lightning-button>
    </lightning-card>
</template>

Anyone who has any Salesforce System Admin or Developer experience knows that in order to delete a record you need its unique ID: its record ID.

Let’s look at the lightning button. When it is clicked it takes the bound variable recordId and executes deleteAccount() in the JavaScript. We will see where the record ID comes from when we look at the JavaScript.

Code: deleteAccount.js