Skip to content

Override standard “New” button with a Lightning Component in order to set default values for some fields.

Hi there, In this blog, we will learn how we can override the standard page of the “New” button for Lead object in order to set default values for some fields (say company and website). Let’s do it. Step 1: Create a lightning Component
<aura:component implements="flexipage:availableForAllPageTypes,
lightning:actionOverride" access="global" >
 <!-- Handler -->
 <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
Step 2: Write below code in the controller.
 // This function will come into action after the component initializes and before rendering.
 doInit : function (component, event, helper) {
 var createLeadEvent = $A.get("e.force:createRecord");
 "entityApiName": "Lead",
 "defaultFieldValues" : {"Company" :"Salesforce",
 "Website" : ""
Step 3:  Go to the “Lead” Object and click “Buttons, Links, and Actions”  Step 4: Click “Edit” next to the “New” button and select Lightning Experience Override as Lightning Component. Step 5: Select c:NewLead as the component to override with. Add Lightning Component to New button Note: It doesn’t matter what order the interfaces appear in. “lightning:actionOverride” is the interface that instructs Lightning Experience to let us use this component to override a standard button or action.  
Published inCoding Mania

One Comment


    Thanks, Avi, It was of great help.

Leave a Reply

Your email address will not be published. Required fields are marked *