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

Best Practices for Building Prompt Templates

 Hi, The following best practices should be considered when building prompt templates: Make sure that your prompt templates are concise and ...