0

I have a custom aura component for record creation. The onload() function calls the apex method to load values in the form. When I try to submit the form by using onsubmit(), the new record is created but its not showing the pre populated values on the new record created. I tried using event.preventDefault() and manually setting the field values in the onsubmit() handler, its not submitting the form, neither its creating a record, it throws an error saying that the record already exists with the lookup values.

In the form I'm doing the following lines of code to capture the values:

<lightning:inputField aura:id = "candidateSummaryField" feildName = "Candidate_Summary__c" />
<lightning:inputField aura:id = "stageField" fieldName = "Stage__c"/>

In the controller in the onload() handler:

var stageFieldValue = component.find("stageField").set("v.value", "Contacted");
var candidateSummaryFieldValue = component.find("candidateSummaryField").set("v.value", result[0]['Candidate_Summary__c']);

In the controller in the onsubmit() handler:

handleSubmit : function(component, event, helper) {
        console.log("Inside handleSubmit");
        event.preventDefault();
        var fields = event.getParams('fields');
        console.log("fields::::: "+JSON.stringify(fields));
        fields['Candidate_Summary__c'] = 'New Candidate Summary';
        fields['Stage__c'] = 'Contacted';
        component.find("applicantForm").submit(fields);
    }

Kindly suggest what I might be missing here, which is not allowing me to achieve record creation with already pre populated values from the form.

Thanks!

0

Please check typo. feildName should be fieldName.

Also...

After prevent default try this component.find("Candidate_Summary__c").set("v.value", "New Candidate Summary");

Also... check that the form is found with component.find('applicantForm') before calling submit.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.