Hi, here we have shown how to insert data in to lead object using Lightning Component.
Apex Controller
public class insertleadrecords {
@AuraEnabled
public static void createLead(Lead le){
insert le;
}
}
Component : InsertLeadRecords
<aura:component controller="insertleadrecords">
<aura:attribute name='lea' type='Lead' default="{sobjecttype:'Lead'}"/>
<lightning:input label='LastName' value='{!v.lea.LastName}'/>
<lightning:input label='Company' value='{!v.lea.Company}'/>
<lightning:input label='Status' value='{!v.lea.Status}'/>
<lightning:button label='submit' onclick='{!c.submitfunction}'/>
</aura:component>
Js Controller
({
submitfunction : function(component, event, helper) {
var lee = component.get('v.lea');
var a = component.get('c.createLead');
a.setParams({'le':lee});
a.setCallback(this,function(r){
component.set('v.lea',r.getReturnValue());
});
$A.enqueueAction(a);
},
})
Application
<aura:application extends="force:slds">
<c:InsertLeadRecords/>
</aura:application>
Output