+ Start a Discussion
VSK98VSK98 

How to Insert/Create a record using Dynamic Lightning:recordEditForm?

Hello All,

I am trying to insert account record on ONLOAD of the page with dynamic Lightning:recordEditForm but i could n't able to crack it. Could you please guide me where i did mistake.

Snippet:
 
init: function(component, event, helper) {
        // First, create children
        $A.createComponents([
            ["lightning:inputField", { fieldName: "Name", value: "Test"}],
            ["lightning:inputField", { fieldName: "Industry", value: "Test" }]
        ], (components, status, errors) => {
            // Then parent, specifying body of lightning:inputFields
            $A.createComponents(
            [["lightning:recordEditForm", { objectApiName: "Account", body: components }]], 
                            (components, status, errors) => {
         
            component.set("v.recordEdit", components); // i can able to view the fields on UI
            console.log('#####'+JSON.stringify(components));
            component.find("createAccountForm").submit();
             //var payload = event.getParams().response;
       // console.log('#####'+JSON.stringify(payload));
                                
                            });
        });
    }

Regards,
VSK98