3
<aura:component implements="force:appHostable">
<aura:attribute name="recordId" type="String" />
<lightning:card title="Create Reservation">
    <lightning:recordEditForm
                              onsuccess="{!c.handleSuccess}"
                              objectApiName="Campsite_Reservation__c">
        <!-- the messages component is for error messages -->
        <lightning:messages />
        <lightning:inputField fieldName="Campsite__c" value="a041o00000ZWoFbAAL"/> 
        <lightning:inputField fieldName="Reference__c"/>
        <div class="slds-m-top_medium">
            <lightning:button variant="brand" type="submit" name="save" label="Save" />
        </div>
    </lightning:recordEditForm>
</lightning:card>   

({

    handleSuccess: function(cmp, event, helper) {
       var params = event.getParams();
       cmp.set('v.recordId', params.response.id);
    }
})

enter image description here

I'm setting the Id of the master record as the value on the new child record which should get created. When the save button is clicked, an error message is displayed as per the screenshot. Is this a known limitation?

  • check running user apex debug log. Is there an exception to update? – amidstCloud Mar 22 '18 at 8:06
  • Just checked. No debug log is generated for this action. – Ranga Mar 22 '18 at 9:33
  • 2
    I recently hit the same problem (and some others) - see Anyone got a lightning:inputField working for a lookup?. – Keith C Mar 22 '18 at 12:23
  • I found that the "reparent" feature works, but the issue also re-occurs when the user edits a separate record and returns to the form to continue entering information. Thinking this is a bug. – Uyen May 7 '18 at 2:10
5

This is a weird issue even if in the logs the error message is not clear. The log just says REQUIRED_FIELD_MISSING.

{"message":"An error occurred while trying to update the record. Please try again.","stackTrace":"","data":{"message":"An error occurred while trying to update the record. Please try again.","statusCode":400,"enhancedErrorType":"RecordError","output":{"errors":[],"fieldErrors":{"Campsite__c":[{"constituentField":null,"duplicateRecordError":null,"errorCode":"REQUIRED_FIELD_MISSING","field":"Campsite__c","fieldLabel":"Campsite","message":"Required fields are missing: [Campsite__c]"}]}}},"id":"-829756038"}"

There is a workaround available to solve this issue. You have to set the Reparentable Master Detail to true for Campsite__c and it should work.

  • Thanks Saroj. Yes, the workaround works. Ideally it will be good if Salesforce can sort the issue though! – Ranga Mar 22 '18 at 13:14
  • Please mark it as Answer if this answers your question. – Saroj Bera Mar 22 '18 at 18:02
1

Workaround is just enable Child records can be reparented to other parent records after they are created in child object's master relation field.

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.