Form Spring'20 onwards you can create the record with default field values.
Demo
HTML Code
Javascript Controller
Output
This change doesn’t apply to Lightning Out, Lightning communities, or the Salesforce mobile app
Demo
HTML Code
<template>
<lightning-card>
<div class="slds-m-around_medium">
<p>Create Record with pre-populate values in LWC <b></b></p>
<lightning-button label="Create Account" variant="brand" onclick={createRecordWithDefaultValues}></lightning-button>
</div>
</lightning-card>
</template>
Javascript Controller
import { LightningElement } from 'lwc';
import { NavigationMixin } from 'lightning/navigation';
export default class CreateRecordInLWC extends NavigationMixin(LightningElement) {
createRecordWithDefaultValues() {
this[NavigationMixin.Navigate]({
type: 'standard__objectPage',
attributes: {
objectApiName: 'Account',
actionName: 'new'
},
state : {
nooverride: '1',
defaultFieldValues:"Name=Test LWC Acc,AccountNumber=123456,Rating=Hot,Phone=1234568975"
}
});
}
}
Output
it is possible anybody used this and hot success output
ReplyDelete