How to Override Standard Buttons With Lightning Componen

How to Override Standard Buttons With Lightning Component?

A Lightning component is required to implement lightning:actionOverride interface to be used to override a standard action on an object. You can override the View, New, Edit, and Tab standard actions on most standard and all custom objects. By overriding standard actions, you can customize your org using Salesforce lightning components along with completely updating the method you view, edit and create new records.

Following are the steps to override standard buttons with lightning component:

Advertisement

1. Create lightning component

override

JavaScript Controller For Lightning Component:

oveeride3

Here we have used force :showToast and force : navigateToSobject.

Force :showToast Displays a toast notification with a message.

A toast displays a message below the header at the top of a view. The message is specified by the message attribute.This toast displays for 5000ms, with a close button in the top right corner when the mode attribute is dismissible.

override15

force : navigateToSobject Navigates to sObject record mentioned by recordId.

To display the record view, set the record ID on the recordId attribute and fire the event.

The record view contains slides that display the Chatter feed, the record details, and related information. This example displays the related information slide of a record view for the specified record ID.

override16

2. Create apex controller for lightning component

override1

3. Override standard button with lightning component.steps to follow:
a) Go to setup and click objectManager.
b) Select Account and click Buttons, Links and Actions.

override7

c) Select new button and click edit.

over2

d) Select your Lightning Component Bundle from dropdown and click save .

override13

e) In the below screenshot you can see the new button has successfully override with lightning component.

over3

f) Now on the click of new button on account a lightning component will open as it shows in below screenshot.

Override14

Popular Salesforce Blogs