function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Badal ShindeBadal Shinde 

how to create contact record using existing Account Id in Aura lightning?

I want to create contact record using existing account Id in Aura lightning table ? and I want save a row separately in on submit button it perform bulk insert ?

the Output look like this

Controller Code:-

addRowController : function(component, event, helper) { var contactList = component.get("v.contactList"); contactList.push({ 'sobjectType': 'Contact', 'FirstName': '', 'LastName': '', 'Phone': '', 'Email': '', }); component.set("v.contactList", contactList); // component.set("v.showTableFlag", true); }, saveContactController : function(component, event, helper) { var action = component.get("c.saveContactList"); var objId = event.currentTarget.dataset.id; alert('aya'); action.setParams({"conList": component.get("v.contactList"), objId}); action.setCallback(this, function(response) { if (response.getState() === "SUCCESS") { //set empty contact list component.set("v.contactList", []); alert('Contact saved successfully'); } }); $A.enqueueAction(action); }

Apec Class:-

 @AuraEnabled
public static boolean saveContactList(string objId){ Contact objCon = New Contact (id = objId); if(objCon != null){ insert objCon; return true; }else{
return false;
}
}
Leo BishopLeo Bishop
Add Controller name in the Component - Create attributes of ID and Contact List so that we can fetch the records from the controller to Component.
https://www.mylabcorp.me/