+ Start a Discussion
Natraj Subramani 15Natraj Subramani 15 

Null Values Returned in Lightning Controller - Look Up value not displayed

Hi All,

I have the below code in lightning component. I am trying to get some field values to validate in controller and I am getting null when I try to alert it. The record id alone is working.

     <aura:attribute name="recordId" type="id" />
     <aura:attribute name="record" type="Object" />
     <aura:attribute name="CaseRecord" type="Object" />
<force:recordData aura:id="record" fields="Id,Name,Responsibility_Lookup__c,Index_Lookup__c" layoutType="FULL" recordId="{!v.recordId}" targetError="{!v.recordError}" targetRecord="{!v.record}" targetFields="{!v.CaseRecord}"  mode="VIEW"/>

Controller

var getid = component.get('v.recordId');     
var rcname = component.get('v.Responsibility_Lookup__c'); 
alert("SR ID==="+getid);
alert("Resp Name==="+rcname);

I also tried var rcname = component.get('v.CaseRecord.Responsibility_Center_Lookup__c');

Still it comes as null or undefined, any suggestions on how to retrieve case field values in lightning controller ?

Thanks
Natraj
pankul guptapankul gupta
Hi Natraj,

Please try the below in your Component
<aura:attribute name="recordId" type="id" />
<aura:attribute name="record" type="Case" />

And in the controller, modify the below line:
var rcname = component.get('v.record');