SIGN IN SIGN UP

Login to your account

Username or Email *
Password *
Remember Me
LWC Progress | ( Lessons)

Lesson: 24 | Delete a Record


This code defines a Lightning web component (LWC) called DeleteAccount that allows you to delete a record using the deleteRecord function from the lightning/uiRecordApi module.

The component has an @api property called recordId that is set to a default value of '0038b00002in40SAAQ'. This property specifies the Id of the record that you want to delete.

The component also has an @api property called objectApiName which you can use to specify the object type of the record to be deleted.

The deleteRecord() method is called when you want to delete the record. It calls the deleteRecord function from the lightning/uiRecordApi module and passes in the recordId property. If the record is deleted successfully, the then() block is executed and a message is logged to the console. If an error occurs while deleting the record, the catch() block is executed and the error is logged to the console.

You can use this component in another component or in a Lightning page to allow users to delete records. You can also customize the component's UI as needed, for example by adding a button that calls the deleteRecord() method when clicked.


Prev You need to login to have access to the quizzes. Next

Mastered by 13 users.

Lightning Web Components

A. Component Reference (27 lessons)
B. Lightning Web Components | Utilities (11 lessons)
C. Lightning Web Component Guide (41 lessons)
D. Java Script Methods for LWC (23 lessons)
E. HTML (18 lessons)
Go to top