December 18, 2019

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:


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

Lightning Component JavaScript Controller:

  1. ({  
  2.       
  3.     doInit: function(component, event, helper) {  
  4.            
  5.         //Fetching Record Type Id  
  6.         var recordTypeId = component.get( "v.pageReference" ).state.recordTypeId;  
  7.         alert( recordTypeId );  
  8.           
  9.     }  
  10.       
  11. })  

Output:



No comments:

Post a Comment