I've tried using the Id
from a lookup field involving the record being view in my lightning component. I query this data in init
, then set the returned value to theCase
.
<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId,force:hasSObjectName" access="global" controller="PaymentInfoController">
<aura:handler name="init" action="{!c.doInit}" value="{!this}"/>
<aura:attribute name="theCase" type="Case" />
<aura:attribute name="record" type="Object"/>
<aura:attribute name="recordError" type="String"/>
// The_Contact__c is a lookup field
<force:recordData aura:id="contactEditor"
recordId="{!v.theCase.The_Contact__c}"
targetError="{!v.recordError}"
targetRecord="{!v.record}"
fields="Email"
layoutType="Full"
mode="EDIT"
/>
<lightning:input title="Patient Email"
value="{!v.record.Email}" />
<lightning:button variant="brand"
label="Update Email"
onclick="{!c.handleContactUpdated}"/>
When I click the lightning:button
, it does console.log a Contact.Id
. But when I type in the lightning:input
box, I get this error:
Everything I've seen in the docs shows them using the value given from force:hasRecordId
, so it appears to me the only way to use Lightning Data Service.