Creating Records
UsecreateRecord from lightning/uiRecordApi to create new records imperatively.
Parameters
- recordInput (Object): Contains the record data
- apiName (String): The API name of the object (e.g., ‘Account’)
- fields (Object): Key-value pairs of field API names and values
Return Value
Returns a Promise that resolves to an object containing the newly created record’sid and other metadata.
Deleting Records
UsedeleteRecord from lightning/uiRecordApi to delete records. Combine with refreshApex to refresh cached data after deletion.
Parameters
- recordId (String): The 15 or 18-character Salesforce record ID
Return Value
Returns a Promise that resolves when the record is successfully deleted.Benefits
Automatic Caching
LDS automatically caches records and shares them across components
Change Detection
Components automatically update when underlying records change
No Apex Required
Perform CRUD operations without writing server-side code
Security Built-in
Respects field-level and object-level security automatically
