How to get record id from lighting:recordForm in Salesforce?

Sample Code:

Component:


  1. <aura:component >  
  2.       
  3.     <div class="slds-box slds-theme_default">  
  4.           
  5.         <lightning:recordForm  objectApiName = "Opportunity"  
  6.                                layoutType = "Full"   
  7.                                columns = "2"  
  8.                                onsuccess = "{! c.handleSuccess }"/>  
  9.               
  10.     </div>  
  11.       
  12. </aura:component>  

Component Controller:


  1. ({  
  2.       
  3.     handleSuccess : function(component, event, helper) {  
  4.           
  5.         var params = event.getParams();  
  6.         alert(params.id);  
  7.           
  8.     }  
  9.       
  10. })  

Output:



No comments:

Post a Comment