I've got a pretty basic lightning component that pulls some Account information for accounts related to a Case. This component sits in Service Console.
<aura:component implements="flexipage:availableForAllPageTypes,force:hasRecordId" access="global">
<aura:attribute name="recordId" type="Id" />
<aura:attribute name="record" type="Object" />
<aura:attribute name="Account" type="Object" />
<aura:attribute name="Case" type="Object" />
<aura:attribute name="recordError" type="String" />
<force:recordData aura:id="record"
recordId="{!v.recordId}"
targetError="{!v.recordError}"
targetRecord="{v.record}"
targetFields="{!v.Case}"
layoutType="FULL"
mode="VIEW"
/>
<lightning:card iconName="standard:account" title="Account Details" >
<lightning:recordViewForm recordId="{!v.Case.AccountId}" objectApiName="Account">
<div class="slds-box slds-theme_default">
<lightning:outputField fieldName="Name" />
<lightning:outputField fieldName="BillingStreet" />
<lightning:outputField fieldName="BillingCity" />
<lightning:outputField fieldName="BillingState" />
<lightning:outputField fieldName="Phone" />
<lightning:outputField fieldName="Customer_Type__c" />
<lightning:outputField fieldName="Seek_And_Find_Widget_Deployed__c" />
<lightning:outputField fieldName="Seek_And_Find_Widget_Deployed_Dt__c" />
</div>
</lightning:recordViewForm>
</lightning:card>
</aura:component>
When the page loads, it's throwing the following error:
Action failed:
lightning:recordViewForm$controller$handleRecordIdChange [Cannot read
property 'getList' of null]
Component Descriptor
markup://lightning:recordViewForm
Function:
Object.getFields
There is an account related to the case and it does actually pull in the correct data. But it's throwing this error every time. When I remove that specific component from the page, the error goes away.
Best Answer
Your component implements
force:RecordId
, and that you also have therecordId
attribute declared as<aura:attribute name="recordId" type="Id" />
.From the documentation of
force:RecordId
, refer to the excerpt (emphasis mine):In your case, because the
recordId
attribute's type is that ofId
, it is causing a runtime error as mentioned in the documentation.For your component to work correctly, follow one of the below steps:
Remove the
recordId
attribute declaration from your componentOR
Change the type of the
recordId
attribute toString
as<aura:attribute name="recordId" type="String" />