How to get Record Type Id by overriding standard action in Salesforce Lightning?

How to get Record Type Id by overriding standard action in Salesforce Lightning?

Add lightning:actionOverride and lightning:hasPageReference to the list of interfaces in the aura:component tag.

Sample Code:

Lightning Component:

<aura:component implements="lightning:actionOverride, lightning:hasPageReference" >  
     
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>  
     
</aura:component> 

Lightning Component JavaScript Controller:

({  
      
    doInit: function(component, event, helper) {  
           
        //Fetching Record Type Id  
        var recordTypeId = component.get( "v.pageReference" ).state.recordTypeId;  
        alert( recordTypeId );  
          
    }  
      
})

Output:

Leave a Reply