This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { LightningElement, api } from 'lwc'; | |
import { createRecord } from 'lightning/uiRecordApi'; | |
import ACCOUNT_OBJECT from '@salesforce/schema/Account'; | |
export default class MyComponent extends LightningElement { | |
@api objectApiName; | |
@api recordId; | |
handleCreateRecord() { | |
const fields = { | |
Name: 'Test Account' | |
}; | |
const recordInput = { apiName: this.objectApiName, fields }; | |
createRecord(recordInput) | |
.then(response => { | |
this.recordId = response.id; | |
}) | |
.catch(error => { | |
console.error(error); | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment