getRecordCreateDefaults
Use this wire adapter to get default information and data needed to create a record.
getRecordCreateDefaults uses this User Interface API resource.
| Parameter Name | Type | Description | Required? |
|---|---|---|---|
objectApiName | String | A supported object. | ![]() |
formFactor | String[] | The layout display size for the record. An array containing any of these values:
formFactor, use the @salesforce/client/formFactor module. | |
recordTypeId | String | The ID of the record type (RecordType object) for the new record. If not provided, the default record type is used. | |
optionalFields | String[] | An optional array of field names. If an optional field is accessible to the context user, it’s included in the response. Specify names in the format ['ObjectApiName.FieldName']. |
Read the data that's returned by the wire adapter using a property or function.
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’sdataproperty orerrorproperty. - If a function is decorated with
@wire, the results are returned in an object with adataproperty and anerrorproperty.
-
data—Record DefaultsIn the response, don’t use the
recordTypeInfoproperty. Instead, use therecordTypeIdproperty, which is returned for every record. -
error—FetchResponse
To create UI that lets a user create a record, first get information about which fields are required. This adapter’s response contains the default field values for a new record of the object type specified in {apiName}. It also contains object metadata and the corresponding layout for Create mode. In the Salesforce user interface, an admin with “Customize Application” permission can mark a field as required in a layout. When you’re building UI, to determine which fields to mark as required in a layout for create and update, use the ObjectInfo.fields[fieldName].required property.
The ldsGenerateRecordInputForCreate component in the lwc-recipes repo shows an example on how to use getRecordCreateDefaults.
See Also
