0

I am facing a strange issue. I am trying to create a record using lightning:recordEditForm but not able to create a record. I have a master detail relationship field "Account" on object "Book". When I have changed the relation to lookup it is working. But for master detail relationship it is not working. Please help me.

Below is the code

<aura:component implements="force:hasRecordId,flexipage:availableForAllPageTypes">
     <aura:attribute name="recordId" type="Id"/>

    <lightning:recordEditForm  objectApiName="Book__c">
        <lightning:messages />
        <lightning:inputField fieldName="Name" />
        <lightning:inputField fieldName="Account__c"/>

        <lightning:button class="slds-m-top_small" type="submit" label="Create" />
    </lightning:recordEditForm>

</aura:component>

This is the error I am getting enter image description here

2
  • As we can't update the MD field. So that might be issue. Commented Mar 15, 2018 at 11:46
  • I am trying to create the record. But the error is showing like that. Commented Mar 15, 2018 at 13:01

2 Answers 2

1

Appears to be a combination of a bad error message (you are creating not updating) and a limitation of the recordEditForm component. The Component does not appear to handle the condition when you are creating the Detail record in a Master/Detail relationship. One workaround is if you are able to set the Master/Detail field to "reparentable", then the component seems to work.

1
  • Had a similar issue here with lightning:recordForm, and your reparentable option did the trick! Thank you! Commented Jul 17, 2018 at 7:32
-1

Your code is correct. The problem you are entering the data through developer console preview option. Add this component to lightning app or page using lightning app builder then its perfectly works.

You must log in to answer this question.

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