Plat-Dev-201 practice question 21 of 30

A developer must create a Lightning component that allows users to input Contact record information to create a Contact record, including a Salary__c custom field. What should the developer use, along with a lightning-record-edit-form, so that Salary__c field functions as a currency input and is only viewable and editable by users that have the correct field- level permissions on Salary__c?

Full set: 204 questions
Answer options
A: html CopyEdit
B: html CopyEdit
C: html CopyEdit Correct answer
D: html CopyEdit
Correct Answer:
C. html CopyEdit
Explanation

The lightning-record-edit-form component is designed to work with child lightning-input-field components to build a form for a specific record. The lightning-input-field component automatically handles several key aspects: it respects the field's data type from the schema (rendering a currency input for Salaryc), it displays the correct label, and most importantly, it automatically enforces field-level security (FLS). If the running user does not have edit access to the Salaryc field, the component will render as read-only or not at all, depending on their read access, without requiring any custom logic.

Why Incorrect

A. lightning-input is a generic input element. It does not automatically bind to a record's field metadata or enforce field-level security.
B. lightning-formatted-number is a display component used for showing a formatted number in a read-only state, not for user input in an edit form.
D. lightning-output-field is also a display component for showing a field's value in a read-only state, typically used within a lightning-record-view-form.

References

1. Salesforce Developer Documentation, Lightning Web Components Developer Guide, "lightning-record-edit-form": "To create a record edit form, use lightning-record-edit-form and include lightning-input-field components for the fields you want in the form."

2. Salesforce Developer Documentation, Lightning Web Components Developer Guide, "lightning-input-field": "Use this component in lightning-record-edit-form to display and edit the value of a record field... The component displays the field label and value, and enforces field-level security and sharing."

3. Salesforce Trailhead, "Lightning Web Components Basics," Unit: "Work with Salesforce Data": This module demonstrates the use of lightning-record-edit-form with lightning-input-field to create forms that respect the platform's data security model.

Scroll to Top