LWC Create Record
import { LightningElement } from 'lwc';
import Name from '@salesforce/schema/Account.Name';
import Rating from '@salesforce/schema/Account.Rating';
import { ShowToastEvent } from "lightning/platformShowToastEvent";
import { NavigationMixin } from "lightning/navigation";
export default class SampleRecordApi extends NavigationMixin(LightningElement) {
Acc_Fields = [Name, Rating];
recordId = '';
handleSubmit(event) {
console.log(event.detail);
console.log(event.detail.id);
}
handleSuccess(event) {
this.recordId = event.detail.id;
let ev = new ShowToastEvent({
title: "Account created",
message: "Record Id: " + this.recordId,
variant: "success"
});
this.dispatchEvent(ev);
setTimeout(this.hand(), 2000);
console.log('recordIds', this.recordId);
}
hand() {
this[NavigationMixin.Navigate]({
type: 'standard__recordPage',
attributes: {
recordId: this.recordId,
objectApiName: 'Account',
actionName: 'view'
},
});
}
}
Oneplus Audio Days
0 Comments