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
Tyler WoodsTyler Woods 

Spring '18 Component lightning:recordEditForm Not Working as Expected

I'm following the examples as given in the updated documentation.
 
<aura:component>
    <lightning:recordEditForm recordId="003XXXXXXXXXXXXXXX" objectApiName="Contact">
        <lightning:messages />
        <lightning:inputField fieldName="FirstName" />
        <lightning:inputField fieldName="LastName" />
        <lightning:inputField fieldName="Email" />
        <lightning:button class="slds-m-top_small" variant="brand" type="submit" name="update" label="Update" />
    </lightning:recordEditForm>
</aura:component>
Inserting a recordId in the above example results in the following error:
[Error in $A.getCallback() [Cannot read property 'value' of undefined]]
Even the second example, attempting to create a record, is throwing an error:
<aura:component>
    <lightning:recordEditForm aura:id="recordEditForm" 
                           objectApiName="Contact">
        <lightning:messages />
        <lightning:inputField fieldName="Name" />
        <lightning:button class="slds-m-top_small" type="submit" label="Create new" />
    </lightning:recordEditForm>
</aura:component>
In the above code, there are two separate errors happening:

1) I'm getting the error 'Cannot read property 'defaultRecordTypeId' of undefined' even though there are no record types associated with my Conatct object.  To get around this error, I have created a record type and I'm now passing in the recordTypeId.  Updated code looks like:
<aura:component>
    <lightning:recordEditForm aura:id="recordEditForm" 
                           objectApiName="Contact"
                           recordTypeId="XXXXXXXXXXXXX">
        <lightning:messages />
        <lightning:inputField fieldName="Name" />
        <lightning:button class="slds-m-top_small" type="submit" label="Create new" />
    </lightning:recordEditForm>
</aura:component>
2) Now that I'm past the recordTypeId error, I now receive this error:
cannot read property 'fields' of undefined

I understand that this new component is in Beta for the current release, but I wanted to understand if the documentation is incomplete, if I'm making some simple error that I cannot see, or if the feature is not fully functional yet.



 
Troy HoshorTroy Hoshor

The same thing is happening in our org, too-- this error seems to be related to the logic behind the lightning:recordEditForm (IMO).  I don't see anything you (or I) are doing that could be causing this....

If I had to venture a guess what was causing it, it's that the recordEditForm is dealing with fields that are blank, and somewhere in the logic for lightning:recordEditForm it's not handling that data appropriately.

Did you figure out any workaround for this issue??

Tyler WoodsTyler Woods
I actually did get it to work.  However, I didn't do anything different.  
I used the same exact code and it was allowing me to create and edit with lightning:recordEditForm tag.  My best guess is that some sort of error was happening on Salesforce's end, but was corrected.  I ended up not using the component anyway because you cannot eddit any attributes of the lightning:inputFields in the form (like readonly, disabled, etc).
Venkatesh S 4Venkatesh S 4
That is a Field Accessibility issue. If you check the Field Accessibility of that particular field, that should exist with 'Hidden' for that particular record type. When you changed that to 'Editable', it will work fine.
MagulanDuraipandianMagulanDuraipandian
Hi,
I had the same issue. Check the profile permissions and FLS.

http://www.infallibletechie.com/2018/03/lightningrecordeditform-with-lookup.html
KrishnakumariKrishnakumari
Make the fields available in the page layout. If the fields referenced in the code are not placed in the layout, then this error "[Error in $A.getCallback() [Cannot read property 'value' of undefined]]" occurs.
Ant BackhouseAnt Backhouse
I also had this issue. When deploying I had to remember to update the page layout assignments referencing the fields. That did the trick.
Tyler Kauffman 18Tyler Kauffman 18
Krishnakumari's answer solved the problem, that should be the answer.
Mark Robinson 42Mark Robinson 42
Spring '18 Component lightning:recordEditForm Not Working as Expected
 Try this one recordId="{!v.recordID}" - instead of this  recordId="003XXXXXXXXXXXXXXX"