Lightning Data Services for Developers
Lightning data services for developers is used to load, create, edit, or delete a record in the component, without requiring Apex code.Lightning Data Service handles sharing rules and field level security also.In addition to not needing Apex, Lightning Data Service improves performance and user interface consistency.
Services:
1) Loading a Record
To load a record using Lightning Data Service, add the force:recordPreview tag to your component. In the force:recordPreview tag, specify the ID of the record to be loaded, a list of fields, and the attribute to which to assign the loaded record.
2) Saving a Record
To save a record using Lightning Data Service, call saveRecord on the force:recordPreview component, and pass in a callback function to be invoked after the save operation completes.
3) Creating a Record
To create a record using Lightning Data Service, first declare force:recordPreview without assigning a recordId. Then load a record template by calling the getNewRecord function on force:recordPreview. Finally, apply values to the new record, and save the record by calling the saveRecord function on force:recordPreview.
4) Deleting a Record
To delete a record using Lightning Data Service, call deleteRecord on the force:recordPreview component, and pass in a callback function to be invoked after the delete operation completes.
Leave a Comment
Comments (0)