0

I am getting only the below generic error message in lightning:recordForm component.

An error occurred while trying to update the record. Please try again.

enter image description here

But I see the below error in the onerror event parameter.

"message":"An error occurred while trying to update the record. Please try again.","detail":"","output":{"errors":[],"fieldErrors":{"Name":[{"constituentField":"LastName","duplicateRecordError":null,"errorCode":"REQUIRED_FIELD_MISSING","field":"Name","fieldLabel":"Last Name","message":"Required fields are missing: [LastName]"}]}}

     <lightning:recordForm objectApiName="{!v.objectName}" aura:id="recordForm" 
                fields="{!v.fields}" 
                mode="readonly" columns = "{!v.columns}" recordId="{!v.recordId}" onsubmit="{!c.handleSubmit}" onsuccess="{!c.handleSuccess}"  oncancel="{!c.handleCancel}" onerror="{!c.handleError}">
                <lightning:messages />  
                </lightning:recordForm>
7
  • 1
    can you add markup? also have you added ` <lightning:messages />` in your markup? Commented Mar 19, 2019 at 14:19
  • <lightning:recordForm objectApiName="{!v.objectName}" aura:id="recordForm" fields="{!v.fields}" mode="readonly" columns = "{!v.columns}" recordId="{!v.recordId}" onsubmit="{!c.handleSubmit}" onsuccess="{!c.handleSuccess}" oncancel="{!c.handleCancel}" onerror="{!c.handleError}"> <lightning:messages /> </lightning:recordForm>
    – vinny
    Commented Mar 19, 2019 at 15:12
  • Can you edit the question and then add markup? Commented Mar 19, 2019 at 15:13
  • The markup in your question doesn't seem to be the correct one. The mode in there is readonly where you cannot edit a record.
    – Jayant Das
    Commented Mar 19, 2019 at 15:41
  • Jeyanth I have an edit button in the top right corner to change the mode from readonly to edit. Please see my screenshot in the original question.We did this to have only one edit icon instead of having multiple edit icons (in view mode) on each field.
    – vinny
    Commented Mar 19, 2019 at 15:45

1 Answer 1

1

That seems to be the expected behavior for client-side validations using lightning:recordForm. Referring to the Client-Side Validation section in documentation, it mentions the scenario you are experiencing (emphasis mine):

Client-Side Validation

The lightning:recordForm component performs client-side validation on record fields only if you interact with them. For example, if you edit a record that includes a required field and submit the form without interacting with that required field, you see only that an error occurred. The form does not flag the required field as incorrect.

1
  • Jayant I was interacting with the field (I blanked out the value in the required field)
    – vinny
    Commented Mar 19, 2019 at 15:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .