On page load of the Aura Component i'm not able to get logged-in/current user Profile ID or Profile Name using the LDS force:recordData

Here is the code from the component and JavaScript controller

CMP Code

    <aura:attribute name="record" type="Object" />
    <aura:attribute name="simpleRecord" type="Object" />

<force:recordData recordId="{!$SObjectType.CurrentUser.Id}"

JS Controller

    recordUpdate : function(component, event, helper) {
            var changeType = event.getParams().changeType;
            if (changeType === "LOADED" || changeType === "CHANGED"){
                var userProfile = component.get("v.simpleRecord");

In the console logs, userProfile.ProfileId is coming as "Undefined" . Where as if i try to refer the standard Name or Email fields i'm getting the respective values.

  • Please edit your question to describe the specific behavior you are observing. – David Reed Jul 8 '19 at 19:24
  • @DavidReed -- Updated the post – Maverick Jul 8 '19 at 19:31

Since your component requires specific fields from the User record you're loading (rather than desiring to display a specific page layout), you should switch from using layoutType to fields.

Here's what the Lightning developer guide says about the two:

To specify a list of fields to load, use the fields attribute. For example, fields="Name,BillingCity,BillingState".

Alternatively, you can specify a layout using the layoutType attribute. All fields on that layout are loaded for the record. The layout depends on the page layout assignment for the profile. For example, if a user using the Marketing User profile is assigned the default account layout, all fields on that layout are available to that user. Layouts are typically modified by administrators, so layoutType isn’t as flexible as fields when you want to request specific fields. Loading record data using layoutType allows your component to adapt to layout definitions. Valid values for layoutType are FULL and COMPACT.

You'll want to list out in the fields attribute at least "ProfileId,Name,Email", along with any other fields you wish to have populated.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.