Skip to main content

createRecord

Explore practical guides and implementation patterns for this topic.

Posts

Topic LWC
Lightning Web Components

Create and Delete Records in LWC without Apex (Lightning Data Service)

💬 In plain words: You do not always need to write an Apex controller to manipulate data in Salesforce! Lightning Web Components (LWC) provide built-in JavaScript functions called createRecord and deleteRecord . These functions talk directly to the Salesforce database using the Lightning Data Service (LDS), allowing you to build faster, lighter UI components with less code. When building custom user interfaces on the Salesforce platform, reducing server-side code is a major best practice. Writing an Apex class just to insert a single Account or delete a Contact introduces unnecessary maintenance overhead and testing requirements. By using the lightning/uiRecordApi module, your LWC can execute DML operations directly from the browser while automatically respecting the active user's security permissions.
Read article
Topic LWC
Lightning Web Components

How to Set Default Field Values When Creating Records in Salesforce LWC

In plain words: Setting default field values on record creation in LWC means automatically pre-populating input fields with preset business values (like default statuses, current dates, or parent IDs) when the component initializes, so users don't have to enter repetitive information manually. Pre-populating standard or custom fields during record creation speeds up data entry, reduces human error, and improves overall user satisfaction. Using Lightning Data Service (LDS) through the lightning/uiRecordApi module allows you to create records directly on the client side with custom default values—without writing custom Apex insertion code.
Read article