+ Start a Discussion
sheila srivatsavsheila srivatsav 

How to get the field value using lightning data service

I have a custom field called status__c in the case object.

This field status__c is a picklist with values like "In-Progress", "Closed" etc.

My requirement is to use a lightning data service to fetch the value of this field in the donit event of my lightning component.

In the doInit event of lightning component I will be doing like this

if (status__c != Closed)
{
    helper.callsomelogic(component,helper)
}

 <aura:attribute name="casememberError" type="String" description="Error In LDS"/>
    <aura:attribute name="casemembership" type="Object" description="Access Record with field Name Status to get the Value"/>
<aura:attribute name="recordId" type="String" description="case RecordID"/>

<force:recordData aura:id="caseRecord"
            recordId="{!v.recordId}"
            fields="Status__c"
            targetRecord="{!v.casemembership}"
            targetFields="{!v.casesimpleMembership}"
            targetError="{!v.casememberError}"/> 

Pleae let me know how I can achieve this. 
Any help is greatly appreciated.

thanks
sheila
SandhyaSandhya (Salesforce Developers) 
Hi,

Check below link for similar discussion.

https://salesforce.stackexchange.com/questions/224224/lightning-data-service-get-record-value-during-component-initialization-in-con
 
Please mark it as solved if my reply was helpful. It will make it available for other as the proper solution.
                                             
Best Regards
Sandhya