0

I am building a lightning component that needs to allow a series of fields on Case to updated by a community user. This component loads up just fine in Lightning Experience, and even in the Community Builder preview. But when I login to the community as an actual user I see this error: **

Cannot Read Property 'ErrorCode' Of Undefined

** I realize this is likely a record permission or a field accessibility issue, but I have checked and the community profile has visibility and edit permissions to the field. As well as Read/Create/Update on the Case object. Interestingly however, if I load up the case detail standard page layout in community the field is editable. So this seems to be isolated to the lightning:recordEditForm component. Any ideas how to solve for this?

<aura:component implements="forceCommunity:availableForAllPageTypes,flexipage:availableForAllPageTypes,force:hasRecordId" >
<aura:attribute name="recordId" type="String"/>
<lightning:recordEditForm recordId="{!v.recordId}" objectApiName="Case" onerror="{!c.getError}" onload="{!c.onLoad}">
    <lightning:messages />
    <lightning:inputField fieldName="Description" />

    <lightning:button class="slds-m-top_small" variant="brand" type="submit" name="update" label="Update" />
</lightning:recordEditForm>

getError : function(component, event, helper){
        debugger;
        var errorObj = event.getParams();
        var errorString = JSON.stringify(errorObj);
        console.log("@@@@:   " + errorString);
    }

EDIT*** Some additional information, looks like ErrorCode is a paramater returned by the onerror event object. Strinigfy spits out the whole error:

{"message":"Cannot read property 'errorCode' of undefined","detail":"","output":{},"error":{"type":"TRANSPORT_ERROR","details":{}}}

1 Answer 1

1

Trace where your errorCode is located. What the message really means is that the project you are working on cannot find any element, property, or object named errorCode.

This usually happens when you are having typographical errors on variable, method or object name which you are calling.

I will give you an example:

I have an aura attribute <aura:attribute name="errorCode" type="String"/> and I am assigning values to this attribute inside my controller by component.set('v.errorCodes', 'This is an Error'); Notice that the attribute name and the component.set assignment names are different. It will throw you an error

Cannot read property 'errorCodes' of undefined"

Its because you dont have any attribute named errorCodes in your component.

There is usually a trace code for this, have you tried tracing the source of the error by opening the Inspector in your browser?

2
  • I have, the error seems to be generic and produced by some backend onload functions used by the <lightning:recordEditForm> base component. I tried to supply the component with an aura:attribute with the name of the property "ErrorCode", but that didnt seem to help.
    – Allen Mann
    Jan 25, 2019 at 16:09
  • Have you checked your controller onLoad, since you are getting the error upon user login Jan 28, 2019 at 7:20

You must log in to answer this question.

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