Is there a way we can get the value from force:RecordData on init ? I am getting the onclick event of a button.
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
<aura:attribute name="recordId" type="String"/>
<aura:attribute name="showButton" type="Boolean" default="false"/>
<aura:attribute name="Opportunity" type="Object"/>
<aura:attribute name="parentOpp" type="Object"/>
<aura:attribute name="oppLoadError" type="String"/>
<force:recordData aura:id="oppRecordLoader"
recordId="{!v.recordId}"
fields="Id,
Name,
AccountId,
Cohort_Sem__r.End_date__c,
LeadSource,
Staff_Referral_Detail__c,
lead_source_detail__c"
targetRecord="{!v.Opportunity}"
targetFields="{!v.parentOpp}"
targetError="{!v.oppLoadError}"
/>
JS:
doInit: function(component, event, helper) {
var opp = component.get("v.parentOpp");
console.log('Name Value: '+ opp.Name);
}
Error:
Action failed: c:createIWSRecord$controller$doInit [Cannot read property 'Name' of null] quickActionHandlerHelper.js failed to create component - forceChatter:lightningComponent