I have an Issue with this component. When every Try to submit a new OpportunityLineItem The component sends the following error messages.

An error occurred while trying to update the record. Please try again.
ProdConfigCreateOppItem.js:59 undefined
ProdConfigCreateOppItem.js:60 REQUIRED_FIELD_MISSING
ProdConfigCreateOppItem.js:61 Required fields are missing: [OpportunityId]

The problem is that I'm actually sending the required fields, also, I've tried Intercepting the request, and adding the fields manually in an onsubmit function. I read the component documentation and no hint about this.

Any Idea what It's wrong?

        <lightning:messages />

        <lightning:inputField fieldName="Product2Id" /> 
        <lightning:inputField fieldName="UnitPrice" />
        <lightning:inputField fieldName="Quantity" />
        <lightning:inputField fieldName="ServiceDate" /> 
        <lightning:inputField fieldName="Description" /> 
        <lightning:inputField fieldName="OpportunityId" value="{!v.oppId}"/>
        <div class="slds-m-top_medium">
            <lightning:button variant="brand" type="submit" name="save" label="Add" />
  • Is the OpportunityId correct in the fields parameter in your onsubmit handler before you set it manually? Or does it come through blank when the form is submitted? – John Towers Sep 8 '18 at 2:22
  • The problem absolutely looks to be in the framework as how the default submit is being handled. I was able to replicate the issue that you are having if using what you have here. But when I customized the create process using a custom apex aura method, I was able to pass all the values and was able to create a new opportunity line item without any issue. – Jayant Das Sep 9 '18 at 0:54
  • Actually, that was the only workaround, I could find, using the onsubmit, and preventing default instead using an aura enabled method, but,well that is not the point of the recordEditForm, I am looking how can I submit the issue on the developer community. – ekiim Sep 9 '18 at 2:43
  • You will need to open a case to the support – Jayant Das Sep 9 '18 at 13:50

looks like you need to use recordId attribute for lightning:recordEditForm.I am not very much sure on this.since you have not posted entire code.PFB my sample code.i am also doing the same thing and its working.

<lightning:recordEditForm aura:id="editForm" recordId="{!v.recordId}"
        <div class="slds-media">

            <div class="slds-media__body">

                <lightning:layout multipleRows="true">
                    <lightning:layoutItem size="6">
                        <lightning:inputField fieldName="Prefix__c"/>
                    <lightning:layoutItem size="6">
                        <lightning:inputField fieldName="First_Name__c"/>
                    <lightning:layoutItem size="6">
                        <lightning:inputField fieldName="Last_Name__c"/>
                    <lightning:layoutItem size="6">
                        <lightning:inputField fieldName="Title__c"/>
                <lightning:layout horizontalAlign="center" class="slds-m-top_large">
                    <lightning:button variant="neutral" label="Cancel" title="Cancel" type="text" onclick="{!c.gotoURL}"/>
                    <lightning:button variant="brand" label="Save" title="Save" type="submit"/>

let me know if it works.

  • According to the documentation, when no ID provided, It is a creating record form. developer.salesforce.com/docs/component-library/bundle/… – ekiim Sep 8 '18 at 16:18
  • You don't need to provide the recordId attribute if the component is used to create a new record, which is what OP has mentioned -- Try to submit a new OpportunityLineItem – Jayant Das Sep 8 '18 at 23:54

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.