Working with Salesforce Data

To create, read, and update Salesforce data from an Aura component, use Lightning Data Service via force:recordData or the form-based components. To delete Salesforce data, use force:recordData.

  • Lightning Data Service

    Use Lightning Data Service to load, create, edit, or delete a record in your component without requiring Apex code. Lightning Data Service handles sharing rules and field-level security for you. In addition to simplifying access to Salesforce data, Lightning Data Service improves performance and user interface consistency.

  • Using Apex

    Use Apex to write server-side code, such as controllers and test classes. Use Apex only if you need to customize your user interface to do more than what Lightning Data Service allows, such as using a SOQL query to select certain records. Apex provisions data that’s not managed and you must handle data refresh on your own.