0

I have a component with an attribute. I try to pass the value to the controller without succes. How do I achieve this.

Aura component

    <aura:attribute name="currentUser" type="User"/>

<force:recordData aura:id="recordLoader" recordId="{!$SObjectType.CurrentUser.Id}"  fields="Return_URL__c" targetFields="{!v.currentUser}"/>
     {!v.currentUser.Return_URL__c}

Controller

let userCustomField = component.get("v.userRecord").Return_URL__c;

The field is rendering correctly in the component. What am I mising. Thanks in advance

1 Answer 1

1

The attribute was called currentUser, but you wrote v.userRecord in your controller/helper. Also, force:recordData loads data asynchronously, so you can't access that data in init. Instead, wait for the record to be loaded:

<force:recordData recordUpdated="{!c.init}" ...

You must log in to answer this question.

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