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

How to include a screen flow in a Lightning Web Component

 Hi, Assume  you have a flow called "Quick Contact Creation" and API Name for the same is "Quick_Contact_Creation". To i...