Similar to this question posted last year. I am calling the submit function from a lightning:recordEdit
from the js controller. However, in my use case the form is creating a new record, and I now want to get the id of that record after it is created so the parent component can use it. The button for submitting/saving the record lives on the parent component.
As noted in the comments in the previously linked question, the onSubmit
function does not get called when submitting in this way - how can I get the Id of the record that was created?
component code:
<lightning:recordEditForm
aura:id="recordForm"
recordId="{!v.recordId}"
objectAPIName="My_Object__c"
onSubmit="{!c.handleSubmit}">
<lightning:inputField fieldName="Name" />
</lightning:recordEditForm>
my controller code:
var record = component.find('recordForm');
record.submit();
I've tried doing:
var record = component.find('recordForm');
var res = record.submit();
However res
is undefined
in this scenario.