Newer Version Available
Creating an Aura Component for Use as an Action Override
1<aura:component
2 implements="lightning:actionOverride,force:hasRecordId,force:hasSObjectName">
3
4 <article class="slds-card">
5 <div class="slds-card__header slds-grid">
6 <header class="slds-media slds-media_center slds-has-flexi-truncate">
7 <div class="slds-media__body">
8 <h2><span class="slds-text-heading_small">Expense Details</span></h2>
9 </div>
10 </header>
11 <div class="slds-no-flex">
12 <lightning:button label="Edit" onclick="{!c.handleEdit}"/>
13 </div>
14 </div>
15 <div class="slds-card__body">(expense details go here)</div>
16 </article>
17</aura:component>In Lightning Experience, the standard Tab and View actions display as a page, while the standard New and Edit actions display in an overlaid panel. When used as action overrides, Aura components that implement the lightning:actionOverride interface replace the standard behavior completely. However, overridden actions always display as a page, not as a panel. Your component displays without controls, except for the main Lightning Experience navigation bar. Your component is expected to provide a complete user interface for the action, including navigation or actions beyond the navigation bar.
Access Current Record Details
Components you plan to use as action overrides usually need details about the object type they’re working with, and often the ID of the current record. Your component can implement the following interfaces to access those object and record details.
- force:hasRecordId
-
Add the force:hasRecordId interface to an Aura component to enable the component to be assigned the ID of the current record. The current record ID is useful if the component is used on a Lightning record page, as an object-specific custom action or action override in Lightning Experience or the Salesforce app, and so on.
- force:hasSObjectName
-
Add the force:hasSObjectName interface to an Aura component to enable the component to be assigned the API name of current record’s sObject type. The sObject name is useful if the component can be used with records of different sObject types, and needs to adapt to the specific type of the current record.