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

  • As we can't update the MD field. So that might be issue. – Tushar Sharma Mar 15 '18 at 11:46
  • I am trying to create the record. But the error is showing like that. – Krishnakumari Y Mar 15 '18 at 13:01
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.

  • Had a similar issue here with lightning:recordForm, and your reparentable option did the trick! Thank you! – Brian Miller Jul 17 '18 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.

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.