I'm having trouble implementing a solution when using an action in the account context, calling a component that passes certain fields to an apex controller. The idea is to use Lightning data service.

This is the component I have so far:

<aura:component controller="CallInformaDBController" implements="flexipage:availableForRecordHome,force:lightningQuickActionWithoutHeader, force:hasRecordId">
    <aura:attribute name="account" type="Object"/>
    <aura:attribute name="simpleAccount" type="Object"/>
    <aura:attribute name="accountError" type="String"/>
    <force:recordData aura:id="accountRecordLoader"


More specifically, How do I access the fields Name and Nif__c in the Javascript controller?

  • What is your specific question about using Lightning Data Service? It looks like you have declared the component correctly. Can you edit your question to include a specific issue or error message you're struggling with?
    – David Reed
    Oct 3, 2018 at 13:23

1 Answer 1


The easiest way to access the loaded fields is via the component attribute named in the targetFields attribute of the force:recordData component. Say you're in a JavaScript controller method; you'd do something like this:

doSomething: function(component, event, helper) {
    // ... do things ...

    var accountName = component.get('v.simpleAccount').Name;

    // ... continue processing, run Apex server method, etc ... 

Keep in mind that force:recordData loads data asynchronously. Your record is not guaranteed to be loaded at the point that your component's init handler goes off (or at any other point, for that matter), so be aware that you may not always have access to populated values.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .