function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Miguel Alejandro SalgadoMiguel Alejandro Salgado 

lightning:recordEditForm, mark as missing a field that I'm passing

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:recordEditForm
            onload="{!c.handleLoad}"
            onsuccess="{!c.handleSuccess}"
            onerror="{!c.getError}"
            objectApiName="OpportunityLineItem"
            aura:id="createOppItem">
            <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" />
            </div>
    </lightning:recordEditForm>


 
Nilesh C RathodNilesh C Rathod
Hi,

It might be weird solution but it worked in my cases

Add following snippet at your code after line 14
<div style="display:none;">
<lightning:input name="opptyId" label="Oppty Id" value="{!v.oppId}" />
</div>