[SalesForce] Create new record with default values LWC

how to navigate to new record create a page with some default values as we do in a lightning $A.get("e.force:createRecord") in LWC

I have tried the below code, but not working:

           this[NavigationMixin.Navigate]({
                type: 'standard__objectPage',
                attributes: {
                    objectApiName: 'Corrective_Action__c',
                    defaultFieldValues: {
                        "Key_Action__c" : this.principlerecid
                    },
                    recordTypeId : this.correctiveActionId,
                    actionName: 'new'
                }
            },true);

Best Answer

This is a kind of limitation in Lightning web Component. Setting default values isn't yet supported, and planned for an upcoming release.

I have created one idea on this:- Allow setting pre-default values in record form by navigation service in LWC

You can upvote this. For time being continue using force:createrecord in your aura Component.

Update

In spring 20, this feature has been delivered by Salesforce.

See this link. According to it, We can do this as follow:-

this[NavigationMixin.Navigate]({
            type: 'standard__objectPage',
            attributes: {
                objectApiName: 'Account',
                actionName: 'new'                
            },
            state : {
                nooverride: '1',
                defaultFieldValues:"Name=Salesforce,AccountNumber=A1,AnnualRevenue=37000,Phone=7055617159"
            }
});