How to get record id in lightning:recordEditForm?

Component:


  1. <aura:component >  
  2.       
  3.     <div class="slds-box slds-theme_default">  
  4.           
  5.         <lightning:recordEditForm  objectApiName = "Opportunity"  
  6.                                onsuccess = "{! c.handleSuccess }">  
  7.             <lightning:inputField fieldName="Name" />  
  8.             <lightning:inputField fieldName="StageName" />  
  9.             <lightning:inputField fieldName="CloseDate" />  
  10.             <lightning:inputField fieldName="AccountId" />  
  11.           
  12.             <lightning:button class="slds-m-top_small"   
  13.                               variant="brand"   
  14.                               type="submit"   
  15.                               name="update" label="Update" />  
  16.               
  17.         </lightning:recordEditForm>  
  18.               
  19.     </div>  
  20.       
  21. </aura:component>  

Component Controller:


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

Output:



No comments:

Post a Comment