createRecord(recordInput)

Creates a record.

createRecord uses this User Interface API resource.

Parameter NameTypeDescriptionRequired?
recordInputObjectA RecordInput object used to create the record.Yes

recordInput takes two properties.

Property NameTypeDescriptionRequired?
apiNameStringThe API name of a supported object.Yes
fieldsObjectMap of field names to field values.

Passing in allowOnSaveDuplicate or recordTypeId isn't currently supported. To prevent the creation of duplicate records, use a duplicate rule with a matching rule.

A Promise object that resolves with the created record. The record contains data for the fields in the record layout.

Before you use this wire adapter, make sure that there isn’t an easier way to create the data. Consider using the lightning-record-*-form components to work with records. To update a record, use updateRecord instead.

Use createRecord by passing in the record input. To create a RecordInput object, use generateRecordInputForCreate(record,objectInfo). Alternatively, pass in a recordInput object with the apiName and fields properties.

See Also