<lightning:recordForm> not capturing validation errors in Component's controller
Last updated 2022-04-05 ·Reference W-5239704 ·Reported By 151 users
In Review
Summary
When you define a custom validation defined on an object & use <lightning:recordForm> in lightning component, you will notice the validation errors doesn't get captured in the components helper class even though the error displays on the User Interface.
Repro
1. Create a validation rule on Account object.
2. Try to create a lightning component & related controller using below sample code snippet.
3. Try creating the record via lightning component.
4. You will notice the validation error displays on the UI however if you try to debug in related controller you will notice the event.getParams(); method returns null.
Test.cmp:
=======
<aura:component implements=""force:appHostable,flexipage:availableForRecordHome,lightning:isUrlAddressable,lightning:actionOverride" access="global">
<aura:attribute name="fieldsList" type="String[]" default="['Name', 'Website', 'Phone']"/>
<lightning:messages aura:id="emessages"/>
<lightning:recordForm aura:id="newaccountform" objectApiName="Account" fields="{!v.fieldsList}" columns="2" mode="edit" onerror="{!c.handleError}" />
</aura:component>
TestController.cmp:
===============
({
handleError: function(component, event) {
alert('Error Here' +event);
console.log(event);
var errors = event.getParams();
console.log("Error Response", JSON.stringify(errors));
}
})
Workaround
NA
Reported By (151)










































Is it Fixed?
Any unreleased services, features, statuses, or dates referenced in this or other public statements are not currently available and may not be delivered on time or at all. Customers who purchase our services should make their purchase decisions based upon features that are currently available.