Skip to content

Instantly share code, notes, and snippets.

@arun12209
Created January 15, 2023 14:10
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save arun12209/88c87804d53944336c266d7471cc6b14 to your computer and use it in GitHub Desktop.
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