Use this wire adapter to get a record’s data.
getRecord wire adapter uses this User Interface API resource, but doesn’t support all its parameters.
recordId—(Required) The ID of a record from a supported object.
layoutTypesis required) A field or an array of fields to return. If the context user doesn’t have access to a field, an error is returned. If you’re not sure whether the context user has access to a field and you don’t want the request to fail if they don’t, use the
Specify field names in the format
Polymorphic fields aren't supported. Including a polymorphic field in
fieldscan result in an invalid field error.
layoutTypesis required) Specifies the fields to return. If this property is specified, the response is a union of
Compact—Use this value to get a layout that contains a record’s key fields.
Full—Use this value to get a full layout. Not all objects support layouts, for example, the Report object doesn’t include a
describeLayout()call. In this case, we recommend using
optionalFieldsto specify a default set of fields.
To improve performance, specify fields instead of a layout whenever possible. Specify a layout only when you want the administrator, not the component, to control the fields that are provisioned. The component must handle receiving every field that is assigned to the layout for the context user.
layoutTypesis specified. If
layoutTypesis not specified, this parameter is ignored.) The access modes for the record. This value determines which fields to get from a layout. Layouts have different fields for create, edit, and view modes.
Create—Use this mode if you intend to build UI that lets a user create a record.
Edit—Use this mode if you intend to build UI that lets a user edit a record.
View—(Default) Use this mode if you intend to build UI that displays a record.
optionalFields— (Optional) An optional field name or an array of optional field names. If a field is accessible to the context user, it’s included in the response. If a field isn’t accessible to the context user, it isn’t included in the response, but it doesn’t cause an error. Specify field names in the format
propertyOrFunction—A private property or function that receives the stream of data from the wire service. If a property is decorated with
@wire, the results are returned to the property’s
errorproperty. If a function is decorated with
@wire, the results are returned in an object with a
dataproperty and an
In the Record response, don’t use the
recordTypeInfoproperty. Instead, use the
recordTypeIdproperty, which is returned for every record.
To filter by criteria and work with dynamic record IDs easily, consider using the GraphQL wire adapter instead.
This example loads the record with required and optional fields. Use
getFieldValue to get a record and display its fields values. Replace the
recordId value with your own.
Load the field values in a custom user interface.
This example loads the record by layout. Replace the
recordId value with your own. Similar to the previous example, you can render field values using the
getFieldValue wire adapter.
See Get Record Data for an example of using
getRecord with a custom UI.
Use a Promise with
catch() blocks. To display errors, use toasts provided by the
- Understand the Wire Service
- Handle Errors in Lightning Data Service
- Salesforce Objects Supported by lightning/ui*Api Modules
- Get Record Data
- updateRecord(recordInput, clientOptions)