Think. Build. Salesforce Solutions.

Salesforce Consulting Services across Salesforce Clouds & Across App Lifecycles


A Comprehensive Guide to Overriding the “New” Button

By |2024-02-26T10:53:21+00:00February 26th, 2024|

Salesforce, a leading CRM platform, empowers organizations with a wide array of customization options. Among these, overriding the default behavior of the “New” button stands out as a powerful technique. This customization provides administrators and developers the capability to design a personalized, efficient, and business-specific user experience for creating new records. In this comprehensive guide, we’ll delve into the why, the how, and the considerations of overriding the “New” button in Salesforce.

Why Override the “New” Button?

The default “New” button in Salesforce serves as a convenient tool for initiating the creation of a new record. However, it might not always align perfectly with the unique requirements of diverse organizations.

Salesforce’s out-of-the-box functionalities may fall short in providing the necessary level of customization required to streamline data entry processes or enforce specific business rules. This is where the concept of overriding the “New” button comes into picture.

The Role of Visualforce Pages and Lightning Components

Salesforce customization revolves around two key technologies: Visualforce and Lightning components. These technologies empower developers to design and implement custom user interfaces that go beyond the capabilities of standard Salesforce layouts.

1. Visualforce Pages: Crafted using a markup language resembling HTML, Visualforce pages provide a versatile way to design forms. They enable the inclusion of custom input fields, validation logic, and dynamic content. When overriding the “New” button, Visualforce pages act as a canvas where developers define the layout and behavior of the new record creation page.

2. Lightning Components: In the context of Salesforce Lightning Experience, Lightning components offer a more modern and interactive approach to customization. Written in Aura, the Lightning Component Framework provides a structured and modular way to design user interfaces. When overriding the “New” button using a Lightning component, developers can create visually appealing, dynamic forms with a consistent look and feel.

Understanding the Mechanism: Overriding the “New” Button

Before exploring the advantages and limitations of overriding the “New” button in Salesforce, let’s grasp the fundamental mechanisms behind this customization technique.

1. Visualforce Page Override

Visualforce pages are a foundational part of Salesforce customization. When overriding the “New” button using a Visualforce page, you essentially replace the default page with a custom-designed page. This page can include various elements such as input fields, buttons, and logic tailored to meet specific business needs.

Step 1: Create a Visualforce Page

Begin by crafting a Visualforce page, essentially an HTML-like markup language, representing the form for creating a new record. This is where you define the layout, structure, and behavior of the new record creation page.

<apex:page standardController=”Account”>
<apex:pageBlock title=”Account”>
<apex:commandButton action=”{!save}” value=”Save” style=”display:block; margin:0 auto;”/>
<apex:pageBlockSection title=”Enter Details” columns=”1″>
<apex:inputField value=”{!Account.Name}”/>
<apex:inputField value=”{!Account.Type}”/>

Step 2: Override the “New” Button

1. Navigate to the Salesforce Setup menu, find the desired object
2. Click on “Buttons, Links, and Actions.” And Locate the “New” button

Overriding the New Button
3. Click the dropdown of the new button and click on Edit.
4. Under Salesforce Classic Override select Visualforce page and choose your Visualforce page from the dropdown.
5. Now go to the object and click on New Button

override new button with lwc
6. Now, when users click the “New” button for the specified object, your Visualforce page will be invoked, for creating new records.

Override New Button

2. Lightning Component Override

Lightning components represent a more modern and dynamic approach to customization, especially in the context of Salesforce Lightning Experience. When overriding the “New” button using a Lightning component, you leverage a more interactive and visually appealing user interface.

Step 1: Create Lightning Component

Create a new Lightning Component using the Developer Console or your preferred development environment. Here’s a basic example:

<aura:component implements=”force:lightningQuickAction,force:hasRecordId”>
<aura:attribute name=”recordId” type=”String”/>

<lightning:card title=”New Account”>
<div class=”slds-p-around_medium”>
<lightning:input aura:id=”accountName” label=”Account Name”/>
<lightning:input aura:id=”accountType” label=”Account Type”/>
<lightning:button label=”Save” onclick=”{!c.saveRecord}”/>

Step 2: Create Lightning Component Controller

Create a JavaScript controller for your Lightning Component to handle the button click and save logic.
saveRecord : function(component, event, helper) {
var accountName = component.find(“accountName”).get(“v.value”);
var accountType = component.find(“accountType”).get(“v.value”);
var createRecordEvent = $A.get(“e.force:createRecord”);
“entityApiName”: “Account”,
“defaultFieldValues”: {
“Name”: accountName,
“Type”: accountType

Step 3: Override the “New” Button

Follow these steps to override the “New” button with your Lightning Component:

1. Navigate to the Salesforce Setup menu.
2. Find the desired object and click on “Buttons, Links, and Actions.”
3. Locate the “New” button and click on Edit.

Salesforce Override New Button
4. Under Lightning Experience Override select Lightning Component and choose your Aura Component from the dropdown.

Override New Button
5. Save the changes.
6. Now, when users click the “New” button for the specified object, your Lightning Component will be invoked, providing a Lightning experience for creating new records.

New Button Override

Now that we’ve explored the foundational steps in overriding the “New” button, let’s examine the advantages and limitations of this customization approach.

Advantages of Overriding the “New” Button

1. Customized User Experience: One of the primary advantages of overriding the “New” button in Salesforce is the ability to create a customized user experience. Default Salesforce layouts might not always align with the specific needs and workflows of an organization. By utilizing Visualforce pages or Lightning components, businesses can design forms that cater to their unique requirements. This tailored approach minimizes friction in data entry and ensures a more intuitive and user-friendly interface.

2. Improved Data Quality: Overriding the “New” button allows for the implementation of custom validations and processes during record creation. This feature is crucial for maintaining high data quality within the Salesforce platform. Organizations can enforce business rules, data integrity checks, and mandatory field requirements, reducing errors and inaccuracies in the entered data. As a result, the overall reliability of the Salesforce data is significantly enhanced.

3. Enhanced Business Processes: Every organization has its distinct business processes and workflows. Overriding the “New” button empowers businesses to align the record creation process with their specific workflows seamlessly. Whether it involves additional approval steps, automatic field population, or dynamic form elements based on certain criteria, this level of customization ensures that Salesforce becomes a more integral part of the organization’s operational efficiency.

4. Streamlined Workflows: Efficiency is paramount in any business environment. Overriding the “New” button enables the integration of additional fields and functionalities directly into the new record creation process. This integration minimizes the need for users to navigate through various screens or make subsequent edits after the initial record creation. Streamlining workflows contributes to a more productive and time-effective user experience.

Limitations of Overriding the “New” Button

1. Visualforce Limitations: While Visualforce pages provide a robust way to customize the Salesforce interface, they may not deliver the same responsive and dynamic user experience as Lightning components. Visualforce technology predates Lightning, and its limitations become more apparent when aiming for a modern and interactive interface.

2. Limited Flexibility in Standard Objects: Certain standard objects in Salesforce may have limitations regarding the fields and processes that can be customized through overrides. While custom objects offer more flexibility, businesses heavily reliant on standard objects should carefully consider the implications of customization on these entities.

3. Maintenance Overhead: Custom overrides, especially those implemented using Visualforce pages, may require additional maintenance efforts. Salesforce regularly releases updates, and changes to the platform could affect the behavior of custom pages. Organizations should be prepared to conduct periodic reviews and make necessary adjustments to ensure continued compatibility.

4. Compatibility Challenges: Salesforce offers multiple user interfaces, including Salesforce Classic and Lightning Experience. Overrides may behave differently across these interfaces, and ensuring compatibility becomes crucial. Businesses should thoroughly test overrides in various environments to guarantee a consistent and reliable user experience.

In conclusion, overriding the “New” button in Salesforce offers a powerful means to enhance efficiency and user satisfaction. While delivering a personalized experience, improved data quality, and streamlined workflows, it’s crucial to navigate Visualforce limitations, standard object inflexibility, and maintenance challenges. Striking the right balance ensures a seamless implementation, allowing businesses to fully leverage Salesforce for increased productivity and effectiveness. Stay informed, adapt to evolving requirements, and embrace customization for a dynamic and successful Salesforce journey.

Leave A Comment