Wednesday, 4 May 2022

How to auto populate default values when New button is overridden with lwc

 Hi,

The following js code snippet helps to auto-populate values when the New button is overridden.


Code Snippet:

 

 const defaultValues = encodeDefaultFieldValues({

                        Name: 'Salesforce Techbook Foundation',                       

                    });                         

                    this[NavigationMixin.Navigate]({

                        type: 'standard__objectPage',

                        attributes: {

                            objectApiName: 'Account',

                            actionName: 'new'

                        },

                        state: {

                            nooverride: '1',

                            recordTypeId: this.recordtypId,

                            defaultFieldValues: defaultValues

                        }

                    });

eval("$A.get('e.force:refreshView').fire();");


Reference : 

https://developer.salesforce.com/docs/component-library/overview/components

No comments:

Post a Comment

What’s the difference between Einstein Article Recommendations and Suggested Articles?

How Does Einstein Article Recommendations Work? Einstein Article Recommendations helps support agents resolve customer cases efficiently by ...